-在底部更新-
pywin32 & winshell 安装时没有明显错误,但测试代码如下(从此处的示例中提取:winshell 示例):
import winshell
parent = 'H:\MUSIC\TESTC\TESTTB.lnk' # target is H:\MUSIC\TESTB
with winshell.shortcut(parent) as link:
print(link.path)
产生了这个结果:
> Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Traceback (most recent call last):
File "C:\Python33\MyScripts\Audio\shortcut2.py", line 3, in <module>
with winshell.shortcut(parent) as link:
AttributeError: 'module' object has no attribute 'shortcut'
>>>
事实上,winshell 安装可能不正确 - 我应该寻找什么?
PS:系统似乎要求将 python 窗口上的输出格式化为代码,而这显然不是。很好奇为什么。它确实包含一个代码片段,但那不是一回事。
更新 - 文档中显示的大多数其他方法不在 dir(winshell) 输出中(例如,文件方法,如 copy_file):
>>> dir(winshell) >>> ['__RELEASE__', '__VERSION__', '__builtins__', >>> '__cached__', '__doc__', '__file__', >>> '__initializing__', '__loader__', '__name__', >>> '__package__', '__path__']