Python easyGUI 文件浏览 显示文件内容

 1 #提供一个文件浏览夹。让用户选择需要打开的文件,打开并显示文件内容:
 2 
 3 import easygui as g
 4 import os
 5 msg='浏览文件并打开'
 6 title='测试'
 7 default='D:Python练习*'
 8 fileType='全部文件'
 9 filePath=g.fileopenbox(msg,title,default,fileType)
10 
11 with open(filePath) as f:
12     title=os.path.basename(filePath)
13     msg='文件%s的内容如下:'%title
14     txt=f.read()
15     g.textbox(title,msg,txt)
原文地址:https://www.cnblogs.com/scios/p/8386635.html