我用一个随机数发生器来产生5到10的随机数。不会这么难吧?我以前在代码中使用过它(这里有2000行代码,太多了),没有出现任何编码错误。
我的密码对我来说只是复活节彩蛋,但它打破了我所有的密码:...
def slowp(t):
for l in t:
sys.stdout.write(l)
sys.stdout.flush()
x=random.randint(0.1,0.9)
time.sleep(x)
print("")
if act=="++++++++++[>+++++++>++++++++++>+++>+<<<++.>+.+++++++..+++.>++.<.+++.------.--------.>+.>":
slowp("Hey, that is hello world made in brainfuck!")
...
act是一个字符串,其值由用户简单地用act=str(input("type here."))提供。直接在这部分之前完成。
错误消息:Traceback (most recent call last):
File "startgame.py", line 2084, in
slowp("Hey, that is hello world made in brainfuck!")
File "startgame.py", line 140, in slowp
x=random.randint(0.1,0.9)
File "/usr/lib/python3.4/random.py", line 216, in randint
return self.randrange(a, b+1)
File "/usr/lib/python3.4/random.py", line 180, in randrange
raise ValueError("non-integer arg 1 for randrange()")
ValueError: non-integer arg 1 for randrange()
实际的问题是什么?