python怎么遍历集合 Python怎么遍历集合中的字符串

主机教程 建站分享 3年前 (2022-09-25) 239次浏览

文章摘要:python怎么遍历集合 Python怎么遍历集合中的字符串

在python中对集合进行遍历的方法有以下两种 1.使用for循环对集合进行遍历 A = {'1','2',' […]

在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


声明:
若非注明,本站文章源于互联网收集整理和网友分享发布,如有侵权,请联系站长处理。
文章名称:python怎么遍历集合 Python怎么遍历集合中的字符串
文章链接:https://www.7966.org/post/13638.html
转载请注明出处

喜欢 (0)