Python 文件在 MS Visual Studio 2015 中立即关闭 [英] Python file closes instantly in MS visual studio 2015

查看:27
本文介绍了Python 文件在 MS Visual Studio 2015 中立即关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 MS Visual Studio 2015 中运行此文件:

I am trying to run this file in MS visual studio 2015:

# This program says hello and asks for my name.
print('Hello friend!')
print('What is your name?') # ask for their name
myName = input()
print('It is good to meet you, ' + myName)
print('The length of your name is:')
print(len(myName))

我尝试在 Visual Studio 中运行它,但在我输入myName"字段后,输出窗口立即关闭.我尝试将环境更改为 Python3.4 和 IronPython,但在两种环境中结果相同.我试图在 Python3.4.2 Shell 中运行这个文件,它工作正常.你能解决这个问题吗谢谢

I tried to run this in visual studio but after I input the "myName" field, the output window closes instantly. I tried to change the environment to Python3.4 and also IronPython, but the same result in both environments. I tried to run this file in Python3.4.2 Shell and there it works fine. Can you please troubleshoot this problem thanks

推荐答案

在工具"、选项"对话框下,找到Python 工具"和调试"页面.在该页面上,您可以配置控制台是自动关闭还是在成功完成和失败时等待按键按下(基于退出代码).

Under the "Tools", "Options" dialog, find "Python Tools" and the "Debugging" page. On that page, you can configure whether the console closes automatically or waits for a keypress for both cases where it successfully completes and when it fails (based on the exit code).

默认情况下,成功完成后,控制台将自动关闭.如果出现错误终止程序,默认会提示.

By default, on successful completion, the console will close automatically. If an error terminates the program, it will prompt by default.

对于 IronPython 项目,默认调试器是 .NET 调试器,它不考虑这些选项.在项目属性"、调试"中可以切换到Standard Python Debugging,这通常是一个更好的体验(虽然你不能再进入C#代码).

For IronPython projects, the default debugger is the .NET one, which does not respect these options. In "Project Properties", "Debug" you can switch to Standard Python Debugging, which generally is a better experience (though you can no longer step into C# code).

这篇关于Python 文件在 MS Visual Studio 2015 中立即关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆