2

我想运行命令:

print "hello"
print "world!"

从 python 与-c从 bash 的开关,是这样的:

python -c 'print "hello" \n print "world"'

但我无法弄清楚-c切换后字符串中正确的换行符应该是什么。

4

3 回答 3

4

怎么样:

python -c 'print "hello"; print "world"'
于 2013-08-28T00:30:45.977 回答
1

python -c 'print "hello\nworld"'

于 2013-08-28T00:31:23.997 回答
1

有些python语句不能写成一行,所以我推荐这个:

python -c '
print "hello"
print "world"
'

这样for就可以出现诸如此类的语句。

于 2020-02-21T07:17:06.853 回答