首页 > 解决方案 > 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?

标签: pythonbashterminal

解决方案


推荐阅读