简体   繁体   English

有没有办法启动 python inrepeter,这样我就可以 python print('hello world') 而不先按 Enter 键?

[英]Is there a way to start the python intrepeter so i can python print('hello world') without hitting enter first?

Because i would like to execute python scripts from my package.json like so因为我想像这样从我的 package.json 执行 python 脚本

{
    "scripts": {
        "p": "python exec(compile(unhexlify(hex).decode(), '', 'exec'))"
    }
}

Is there any argument we can give to python to make this possible?我们可以给 python 提供任何参数来使这成为可能吗?

You can use -c argument:您可以使用-c参数:

$ python3 -c 'print("hello world")'
hello world

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM