|
发表于 2016-9-20 21:24:50
|
显示全部楼层
3- import easygui as g
- import os
- file_path=g.fileopenbox()
- file=open(file_path)
- text_old=file.read()
- file.close()
- text_new=g.textbox('文件【%s】的内容如下:'%os.path.split(file_path)[1],'显示文件内容',text_old)
- if text_old != text_new:
- chioce=g.buttonbox('检测到文件内容发生改变,请选择以下操作:','警告',('覆盖保存','放弃保存','另存为'))
- if chioce == '覆盖保存':
- file=open(file_path,'w')
- file.write(text_new)
- file.close()
- if chioce == '另存为':
- file_path = g.filesavebox()
- file=open(file_path,'x')
- file.write(text_new)
- file.close()
复制代码 |
|