标题: python求助 实在不明白为什么 [打印本页] 作者: zx770693094 时间: 2018-4-13 17:40 标题: 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