在 MacOs Python shell 中粘贴多行会返回 SyntaxError

Chr*_*ema 2 python macos terminal

我不得不重新安装我的 MacBook。我从brew下载了python。

当我从 brew 复制代码并将其粘贴到 python shell 中时,文本会突出显示,并且代码不会执行。

当我使用 MacBook 上的库存 python 时,没有问题。

请观看这个短视频: https://youtu.be/CrTzBpVdcVM

我不是唯一一个遇到这个问题的人,但尚未找到解决方案:

在Python中粘贴多行时出现语法错误

https://python-forum.io/Thread-How-to-paste-several-lines-of-codes-to-the-Python-console

https://github.com/Homebrew/discussions/discussions/428

Chr*_*ema 6

看来readline有bug(Homebrew用它来安装Python)

简短回答:

echo "set enable-bracketed-paste off" >> ~/.inputrc
Run Code Online (Sandbox Code Playgroud)

长答案: https: //github.com/Homebrew/homebrew-core/issues/68193