python - Can You Call a Single Python Command Without Entering the Python IDE in the Terminal?
问题描述
In the terminal you can type python3
and it will dump you into the Python IDE to run your Python code. You can also type python3 <python-file_name>.py
and it will run the aforementioned Python file. I thought that perhaps python3
was simply a command, so I tried
python3 print("hello")
expecting the terminal to output hello
similarly to just typing echo "hello"
, but it did not. What I got instead was an error saying
bash: syntax error near unexpected token `('
Can you not run python code in the terminal in this way? Do you have to be in the Python IDE for this to work? Or am I missing a command option that would allow this?
解决方案
推荐阅读
- sql - 从查询中的所有列中排除某些数值
- python - Python3中提取“位置”值的最佳方法,特别是从这个片段中提取“lat”和“lng”?
- python - 反斜杠被视为转义字符 Python/Json
- android - 无法使用 NavigationDrawer 设置工具栏菜单
- algorithm - 在图中找到需要访问的节点最少的路径
- reactjs - React Array.map 使用事件渲染多个组件以及如何访问单个组件
- ruby-on-rails - 如何在 has_many 上使用 ransack 实现搜索:通过关联
- linux - 将当前进程 pid 写入 cgroups.procs 失败并出现权限被拒绝错误
- list - PROLOG 列出不同元素的任务
- node.js - 安装 socket.io 时 SocketIO.Server 对象消失