【发布时间】:2014-04-05 06:41:15
【问题描述】:
我正在尝试使用以下 Python 代码显示 6 个随机整数:
#!"E:/PortablePython3.2.5.1/App/python.exe"
import random
print("Content-Type: text/html\n\n")
for k in range(6):
r = random.randint(1, 75)
print("Winning Lotto Numbers: ", r)
我可以得到一个随机整数来显示,但我无法显示剩余的 5。
【问题讨论】:
-
r只是名称 one 整数.. 它被重新分配了 6 次之前它曾经显示一次。 -
您在
for-loop中重复使用r。您可能想在for-loop中写print("Win...)。