大佬教程收集整理的这篇文章主要介绍了如何使用 askfilename() 或类似方法使用 Python,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Epic 将其快捷方式保存为 .url 文件格式,我希望利用 tkinter 的 askopenfilename() 函数来选择快捷方式,然后使用下面的代码打开游戏目录,但是每当我尝试这样具有上述功能的东西我收到“灾难性错误”,有什么办法可以用 tkinter.filedialog 选择它?或者,我可以使用其他任何函数来实现相同的结果吗?
import os
import tkinter.filedialog as fd
target_url = #Here is where I wish to put a fd.askopenfilename() function,but as I described,this doesn't work#
#Thus far the target_url variable is just an input()#
data = open(target_url,mode='r')
data_read = data.read()
data_index = data_read.index("Iconfile=")
exe = data_read[data_index:].replace('Iconfile=','')
replaced = os.path.basename(exE)
open_thing_2 = exe.replace(replaced,'')
os.startfile(open_thing_2)
为了更容易调试,这是此类 .url 文件内容的示例。
[{number_Array}]
Prop3=19,0
[InternetShortcut]
IDList=
IconIndex=0
WorkingDirectory=C:\Program files (x86)\Epic Games
URL=com.epicgames.launcher://apps/Jaguar?action=launch&silent=true
Iconfile=C:\Program files\Epic Games\Game_name\Game_name.exe
感谢您的帮助。
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的如何使用 askfilename() 或类似方法使用 Python全部内容,希望文章能够帮你解决如何使用 askfilename() 或类似方法使用 Python所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。