问题-我如何修复我的代码,使我不能得到这个错误?我想让output放在我的剪贴板缓冲区里(我在Mac上)?
我尝试过的--把output打印到控制台上,效果很好!我尝试过通过pip pyperclip卸载和重新安装。
我注意到的是-我的代码不叫'NSString‘,所以我不知道我在哪里迷路了。object是<class 'str'>。
我在哪里可以找到有用的文档,说明如何解决未来可能出现的这类问题?
#!/usr/bin/env python3
# encoding: utf-8
import pyperclip
output = f"""
Below are the titles and a one-sentence summary/meaning/'stinger' of zettel
I've birthed into existence and their ideas I'm grappling.
"""
# print(output)
# print(type(output))
pyperclip.copy(output)输出
(base) ➜ ~ python wiwov1.py
Traceback (most recent call last):
File "/Users/will/wiwov1.py", line 79, in <module>
pyperclip.copy(output)
File "/usr/local/lib/python3.9/site-packages/pyperclip/__init__.py", line 659, in lazy_load_stub_copy
return copy(text)
File "/usr/local/lib/python3.9/site-packages/pyperclip/__init__.py", line 136, in copy_osx_pyobjc
newStr = Foundation.NSString.stringWithString_(text).nsstring()
AttributeError: module 'Foundation' has no attribute 'NSString'发布于 2021-12-31 21:30:42
我会尝试重新安装pyperclip
pip uninstall pyperclip
pip install --upgrade pyperclip此外,我还将更新代码:
import pyperclip
output = "Below are the titles and a one-sentence summary/meaning/'stinger' of zettel \n I've birthed into existence and their ideas I'm grappling."
pyperclip.copy(output)https://stackoverflow.com/questions/70544844
复制相似问题