Chinaunix

标题: python的-c有什麽用? [打印本页]

作者: flynetcn    时间: 2011-10-27 13:24
标题: python的-c有什麽用?
python的-c有什麽用?即不能单行内写语句,也不能写多行。
作者: New__Bird    时间: 2011-10-27 13:33
python有木有前途啊。
作者: flynetcn    时间: 2011-10-27 13:53
python -c 'if 1: print "ok";else: print "fail";'

这样的语句怎么写才对啊?
作者: flynetcn    时间: 2011-10-27 14:20
不是单单这个语句的问题,是怎么在shell中执行一段python的问题!不用调文件。

python -c 'print "ok" if 0 else "fail"'
--------
这句是行,但是这只是一个表达式,说回来还是一条语句而不是多条。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2