Copy-paste into Python interactive interpreter and indentation

前端 未结 8 1677
借酒劲吻你
借酒劲吻你 2020-12-06 00:41

This piece of code, file test.py,

if 1:
   print \"foo\"
print \"bar\"

can be successfully executed with execfile(\"test.py\

8条回答
  •  Happy的楠姐
    2020-12-06 00:59

    One other solution I recently found for a similar problem:

    $ python << EOF
    if 1:
       print "foo"
    print "bar"
    
    EOF
    

提交回复
热议问题