t=(1111,222,333,444,555) for index,item in enumerate(t): print(index,item)
》》》
0 1111
1 222
2 333
3 444
4 555
import random randomnumber=(random.randint(10,100) for i in range(5)) # print(randomnumber)#得到的结果是生成器对象,需要用tuple转换 print(tuple(randomnumber)) # for i in randomnumber: # print(i,end=‘,‘) # print(randomnumber.__next__())#输出第一个元素 # print(randomnumber.__next__()) # print(randomnumber.__next__())
原文地址:https://www.cnblogs.com/python1988/p/12088457.html
时间: 2024-10-12 08:39:29