如何从bash shell内联执行Python [英] How to execute Python inline from a bash shell
本文介绍了如何从bash shell内联执行Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否存在一个Python参数来从外壳执行代码而无需启动交互式解释器或从文件读取? 类似于:
Is there a Python argument to execute code from the shell without starting up an interactive interpreter or reading from a file? Something similar to:
perl -e 'print "Hi"'
推荐答案
这有效:
python -c 'print("Hi")'
Hi
在手册中,man python
:
-c command
Specify the command to execute (see next section). This termi-
nates the option list (following options are passed as arguments
to the command).
这篇关于如何从bash shell内联执行Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文