我查了一下 inetrnet,但没有发现任何相关内容,所以我在这里问 -
是否可以使用 python 创建文件的快捷方式并将其放入我选择的特定目录中?
例如,我在“C:”中有一个名为“EXAMPLE”的文件夹。我想自动创建谷歌浏览器的快捷方式并将其放在这个文件夹中。是否可以使用 python 来做到这一点(而不仅仅是我自己拖过去)?
谢谢
我假设因为你提到了 C: 你正在使用 Windows。这样就可以使用winshell了
import os, winshell
from win32com.client import Dispatch
desktop = winshell.desktop()
path = os.path.join(desktop, "Media Player Classic.lnk")
target = r"P:\Media\Media Player Classic\mplayerc.exe"
wDir = r"P:\Media\Media Player Classic"
icon = r"P:\Media\Media Player Classic\mplayerc.exe"
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.WorkingDirectory = wDir
shortcut.IconLocation = icon
shortcut.save()
欲了解更多信息,请查看here
如果您使用的是基于 UNIX 的系统,则可以使用符号链接命令。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)