[英]How to create an URL shortcut for Linux in Python?
正如您在問題中看到的那樣,我正在嘗試在Python中為Windows和Linux創建URL快捷方式。
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)
但是對於Linux來說,這是另一個問題,我找不到與Google合作的解決方案。
這是我嘗試的:
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)
謝謝你的時間
順便說一句,解決問題的方法很簡單,只需將linux_shortcut.url
替換為linux_shortcut.desktop
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.