[英]How to run one line Python command in terminal?
I want to get result of a Python function in terminal.我想在终端中获得 Python function 的结果。
I tried to run the command:我试图运行命令:
$ python3 -m uuid uuid.uuid4().hex
And I expect to see the output be something like: '78cbf0fadaa34ff7ac3f7b965965e207'
我希望看到 output 类似于: '78cbf0fadaa34ff7ac3f7b965965e207'
Unfortunately I get error:不幸的是我得到错误:
-bash: syntax error near unexpected token `('
You were close.你很亲密。
-c
and not -m
.运行单个命令的标志是-c
而不是-m
。import uuid
so you can use it.您还需要import uuid
以便使用它。print()
to actually see some output.您还需要使用print()
来实际看到一些 output。$ python3 -c "import uuid; print(uuid.uuid4().hex)"
8e79508445db4aca91bb0990529fdd89
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.