python求助 实在不明白为什么
代码1:c = 0
while c < 100:
a = open("test.txt", 'r+')
aa = str(random.randint(0, 9))
if aa not in a.read():
a.write(aa)
c = c+1
结束后test.txt内容为: 1057849236
代码2:
c = 0
while c < 100:
a = open("test.txt", 'r+')
print(a.read())
aa = str(random.randint(0, 9))
if aa not in a.read():
a.write(aa)
c = c+1
结束后test.txt内容为: 8107706202549583142041856170414081171962862927185540622232384188729478018396560124391461135092853391
代码2就只是多了个输出而已为什么代码2的if判断失效了,直接存进文本了,求解答
你在上面就已经输出了,再下面写任何东西都不会有效了吧。输出语句不都是在最后么?
页:
[1]