QiYongchuan / MyGitBlog

个人博客主页,记录计算机学习,前端-后端-全栈学习ing
22 stars 1 forks source link

python中的数据类型 #79

Open QiYongchuan opened 7 months ago

QiYongchuan commented 7 months ago

python中的数据结构:

Data stractures

list 列表

# define a list of names
names = ["harry","Ron","heri","Ginny"]

dic 字典


# define a dic
houses = {"harry":"Gry","Draco":"Sly"}
houses['Herminoe'] = "Gry"

tuble 元组

coordinateX = 10.0
coordinateY = 20.0

coordinate = (10.0,20,0)

#即相当于直接可以用一个变量来代表两个变量

set


#create an empty set

s = set() 

# add elements

s.add(1)
s.add(2)
s.add(3)
s.add(4)
s.add(4)

s.remove(1)
print(s)   // 234