【Python】Python - 迴圈Set。Python Loop Set.
【Python】Python - 迴圈Set。Python Loop Set.
使用迴圈存取 Items
你可以使用for 迴圈去對 set裡面的item存取:
範例
下面的範例為對set做迴圈,並列印值:
Loop through the set, and print the values:
thisset = {"apple", "banana", "cherry"}
for x in thisset:
print(x)上面輸出: cherrybananaapple
留言
張貼留言