赞
踩
list1.append(x) 将x添加到列表末尾
list1.sort() 对列表元素排序
list1.reverse() 将列表元素逆序
list1.index(x) 返回第一次出现元素x的索引值
list1.insert(i,x) 在位置i处插入新元素x
list1.count(x) 返回元素x在列表中的数量
list1.remove(x) 删除列表中第一次出现的元素x
list1.pop(i) 取出列表中i位置上的元素,并将其删除
特点:
math.pi 圆周率
math.ceil(x) 对x向上取整
math.floor(x) 对x向下取整
math.pow(x,y) x的y次方
math.sqrt(x) x的平方根
math.fsum(list1) 对集合内的元素求和
更多math库函数请参考:https://docs.python.org/3/library/math.html
datetime.strptime(),解析时间字符串
注释:Y表示四位数年份,y表示两位数年份。
datetime.strftime(),格式化datetime为字符串显示
https://docs.python.org/3/library/datetime.html#module-datetime
集合的操作:
例如:身份证号(键)--个人信息(值)
基本操作:
遍历所有的key: for key in d.keys():
print(key)
遍历所有的value: for value in d.values():
print(value)
遍历所有的数据项: for item in d.items():
print(items)
更多random模块的方法请参考:https://docs.python.org/3/library/random.html
import matplotlib.pyplot as plt
#x,y分别是X坐标和Y坐标的列表
plt.scatter(x,y)
plt.show()
强大的N维数组对象array
成熟的科学函数库
使用的线性代数,随机数生成函数等
ndarray.shape 数组的维度
np.random.randint(a,b,size) #创建【a,b)之间,形状为size的数组
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。