If statements and one line python scripts from command line

后端 未结 4 1238
没有蜡笔的小新
没有蜡笔的小新 2020-12-20 16:17

Why do I receive a syntax error for the following one liner python code?

python -c \'import re; if True: print \"HELLO\";\'
  File \"\", line 1         


        
4条回答
  •  自闭症患者
    2020-12-20 16:56

    You can embed newlines directly in the argument.

    $ python -c 'import re
    > if True:
    >  print "HELLO"
    > '
    

提交回复
热议问题