Python检查重量plik.tx

2024-09-29 05:19:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要函数来检查name.txt变量,如果变量将改变print1,如果变量2次又改变print1,那么可以在python中这样做吗

http://pastebin.com/Qa0ed3nM

fr = open("plik.txt",'r')
first_length = len(str(fr.read()))
while True:
    text = str(fr.read())
    if(len(text)!=first_length):
        fr.close()
        fw = open("plik.txt","w")
        fw.write(text)
        fw.close()
        print("done")
        break;

Tags: 函数textnametxtclosereadlenopen