【问题标题】:Create web shortcut in windows in python在python中的Windows中创建Web快捷方式
【发布时间】:2021-08-27 04:16:41
【问题描述】:

Create shortcut files in Windows 10 using Python 3.7.1

这是本地文件的快捷方式

如何创建https://xxxxx.com的快捷方式

【问题讨论】:

    标签: python python-3.x windows shortcut


    【解决方案1】:

    为此,您需要winshell,这将使查找特定于用户的路径和文件夹变得容易。这是脚本:

    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()
    

    【讨论】:

      【解决方案2】:
      with open('shortcut.url', mode='w', newline='\r\n') as f:
          f.write("[InternetShortcut]\nURL=http://example.com")
      

      选项 newline='\r\n' 确保您的脚本在 Mac 或 Linux 上运行时创建有效的 Windows 快捷方式。

      【讨论】:

        猜你喜欢
        • 2011-10-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-09
        • 1970-01-01
        • 2021-11-21
        • 1970-01-01
        • 2023-01-11
        相关资源
        最近更新 更多