Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python中的数据类型 #79

Open
QiYongchuan opened this issue Feb 3, 2024 · 0 comments
Open

python中的数据类型 #79

QiYongchuan opened this issue Feb 3, 2024 · 0 comments
Labels
notes notes

Comments

@QiYongchuan
Copy link
Owner

python中的数据结构:

Data stractures

  • list - sequences of mutable values //列表可以改变[]
  • tuple - sequence of immutable values //元组不可改变()
  • set - collection of unique values //集合不可以重复()
  • dict - collection of key-value pairs // 字典键值对{}

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

@QiYongchuan QiYongchuan added the notes notes label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notes notes
Projects
None yet
Development

No branches or pull requests

1 participant