列表
定义
a = [1,2,3,4,5,6]
type(a)
a[0]
a[4] = 99
切片
a[0:2]
a[1:]
a[:-1]
字典
me = {'height':180}
me['height']
布尔型
True、False
循环语句
for i in [1,2,3]:
print(i)
类
构造函数只在生成类的实例时被调用一次。方法中为什么要加入self,目的是可以调用实例变量。
class 类名:
def __init__(self,参数,...) #构造函数
...
def 方法名1(self,参数,....)
...
Matplotlib
绘制简单图形
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0,6,0.1)
y = np.sin(x)
plt.plot(x,y)
plt.show()
网友评论