如何避免sequence
在以下 Python 代码中手动增加计数器:
sequence = 0
for value in random.sample(range(1000), 7):
# do something with value and sequence
sequence += 1
如何避免sequence
在以下 Python 代码中手动增加计数器:
sequence = 0
for value in random.sample(range(1000), 7):
# do something with value and sequence
sequence += 1
枚举!您可以参考 Python文档。
for sequence, value in enumerate(random.sample(range(1000), 7)):
# do something with value and sequence