【发布时间】:2019-08-20 17:13:06
【问题描述】:
我似乎无法访问我在“打开方式”上使用的文件路径
我正在创建自己的文本编辑器,可以通过打开选项卡(工作)打开文件,也可以使用从脚本转换的 .exe 文件打开 .txt 文件
我尝试了很多不同的方法来访问该文件,但似乎没有任何效果
try:
fileName = str(os.path.realpath(__file__))
with open(fileName) as _file:
contentText.insert(1.0, _file.read())
onContentChanged()
root.title(os.path.basename(fileName) + " - Footprint Editor")
except:
root.title("Untitled - Footprint Editor")
我尝试让 fileName 等于我使用“打开方式”的文件的路径 当 .py 文件转换为 .exe 时
【问题讨论】: