[英]How to create an URL shortcut for Linux in Python?
As you see in the question, I am trying to create an URL shortcut in Python for both Windows and Linux. 正如您在问题中看到的那样,我正在尝试在Python中为Windows和Linux创建URL快捷方式。
Windows shortcut is working, this is my code if somebody needs it : Windows快捷方式正在运行,如果有人需要,这是我的代码:
import os
target = "www.google.com"
with open(os.path.join(shortcut_path, "windows_shortcut.url"), "w") as f:
f.write('[InternetShortcut]\n')
f.write('URL=%s' % target)
But for Linux it is an other problem and I can't find any solution which is working for me with google. 但是对于Linux来说,这是另一个问题,我找不到与Google合作的解决方案。
This is what I tried : 这是我尝试的:
import os
target = "www.google.com"
with open(os.path.join(shortcut_path, "linux_shortcut.url"), "w") as f:
f.write("""[Desktop Entry]
Encoding=UTF-8
Name=Link to google
Type=Link
URL=%s
Icon=text-html
Name[en_US]=commit""" % target)
Thanks for your time 谢谢你的时间
顺便说一句,解决问题的方法很简单,只需将linux_shortcut.url
替换为linux_shortcut.desktop
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.