首页 > 解决方案 > Create web shortcut in windows in python

问题描述

Create shortcut files in Windows 10 using Python 3.7.1

this is for shortcut to local files

How to create a shortcut to https://xxxxx.com

标签: pythonpython-3.xwindowsshortcut

解决方案


You'll be needing winshell for this, which would make finding user-specific paths and folders easy. Here's the script:

import os, winshell
desktop = winshell.desktop()
path = os.path.join(desktop, "ShortcutName.url")
target = "https://xxxxx.com"
shortcut = file(path, 'w')
shortcut.write('[InternetShortcut]\n')
shortcut.write('URL=%s' % target)
shortcut.close()

推荐阅读