溫馨提示×

python怎么遍歷集合

養魚的貓咪
1705
2021-03-08 17:20:27
欄目: 編程語言

python怎么遍歷集合

在python中對集合進行遍歷的方法有以下兩種

1.使用for循環對集合進行遍歷

A = {'1','2','star'}

for item in A:

print(item,end='')

2.使用while對集合進行循環遍歷

A = {'1','2','star'}

try:

while True:

print(A.pop(),end='')

except:

pass

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女