Skip to main content
 首页 » 编程设计

python之Visual Studio 代码终端

2024年12月31日12youxin

当我尝试使用打印命令在终端中运行 Python 代码时,没有任何反应。当我在终端本身尝试 test.py 命令时,下面复制的文本就是输出。

请协助如何让终端打印我的代码。

E:\Kath\Documents\blockchain> test.py 
test.py : The term 'test.py' is not 
recognized as the name of a cmdlet, function, 
script file, or operable program. Check the 
spelling of the name, or if a path was 
included, verify that the path is correct and 
try again. 
At line:1 char:1 
+ test.py 
+ ~~~~~~~ 
    + CategoryInfo          : ObjectNotFound: 
    (test.py:String) [], CommandNotFoundExce 
  ption 
    + FullyQualifiedErrorId : CommandNotFound 
   Exception 

请您参考如下方法:

打开 VS Code 后,通过打开命令面板 (Ctrl+Shift+P) 选择 Python 3 解释器,开始键入 Python: Select Interpreter 命令进行搜索,然后选择命令. 如果可用,您还可以使用状态栏上的选择 Python 环境选项。 现在,创建一个新文件,并将其保存为扩展名 .py。完成此操作后,在工作区中编写所需的代码。然后右键单击工作区 --> 在终端中运行 Python 文件。 这将运行选定的文件。 希望此解决方案有所帮助。