TA的每日心情 | 擦汗 2018-6-1 15:00 |
---|
签到天数: 23 天 连续签到: 1 天 [LV.4]测试营长
|
代码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判断失效了,直接存进文本了,求解答
|
|