手记

python笔记

'''集合'''

s = {3,2,3,5}

print(len(s))

s.add(6)

print(s)

#

'''列表'''

m  =[1,3,4,1]

print(len(m))

m.append(7)

print(m)

#

'''字典'''

d = {'dogs':5, 'cats':4}

print(len(d))

print(d["dogs"])

d["pigs"]=7

print(d.keys())

print(d.values())

from numpy import array
'''数组Numpy Arrays'''
a =array([1,2,3,4])
b = a+2
print(a)
print(b)

'''循环loop'''
line = '1,3,3,4,5'
l = sum([int(field) for field in line.split(',')])
print(l)

0人推荐
随时随地看视频
慕课网APP