【问题标题】:How can I run inline Python code in a command-line shell? [duplicate]如何在命令行 shell 中运行内联 Python 代码? [复制]
【发布时间】:2020-11-18 12:42:43
【问题描述】:

在 shell 中,我可以像这样执行 AppleScript 命令行代码:

osascript -e "tell application \"Finder\" to activate"

在 Python 中是否可能发生同样的事情,例如:

python --execute "print('hello world!')"

【问题讨论】:

标签: python shell command-line


【解决方案1】:

这样的东西应该适合你!

python -c 'print("Hi")'

可能是How to execute Python inline from a bash shell的副本

【讨论】: