Python和VS代码问题
VS代码终端不会输出我的Python代码 我一直在想:Python和VS代码问题,python,python-3.x,Python,Python 3.x,VS代码终端不会输出我的Python代码 我一直在想: PS C:\Users\danie\OneDrive\Documents\Exercise Files\Ch2> cd 'c:\Users\danie\OneDrive\Documents\Exercise Files\Ch2'; ${env:PYTHONIOENCODING}='UTF-8'; ${env:PYTHONUNBUFFERED}='1'; & 'C:/Python/Python37/Python.exe' 'c:
PS C:\Users\danie\OneDrive\Documents\Exercise Files\Ch2> cd 'c:\Users\danie\OneDrive\Documents\Exercise Files\Ch2'; ${env:PYTHONIOENCODING}='UTF-8'; ${env:PYTHONUNBUFFERED}='1'; & 'C:/Python/Python37/Python.exe' 'c:\Users\danie\.vscode\extensions\ms-python.python-2019.5.18875\pythonFiles\ptvsd_launcher.py' '--default' '--client' '--host' 'localhost' '--port' '57829' 'c:\Users\danie\OneDrive\Documents\Exercise Files\Ch2\helloworld_start.py'
我已经设置了launch.JSON文件,如下所示
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "",
"env": {},
"envFile": "${workspaceRoot}/.env",
}
]
这是我的密码:
def main():
打印(“你好世界”)
如果名称=“\uuuuu main\uuuuuuuu”:
main()
我只想打印“hello world”,但似乎我在设置中遗漏了一些内容。调用主函数的最后两行缩进了。这意味着它们是主要功能的一部分 通过删除缩进,当您运行文件并按预期调用main函数时,将执行这两行。看到这个了吗
def main():
print("hello world")
if __name__ == "__main__":
main()