如何防止我的 Python 应用程序在到达代码末尾时自动关闭? [英] How do I prevent my Python application from automatically closing once reaching the end of code?

查看:32
本文介绍了如何防止我的 Python 应用程序在到达代码末尾时自动关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是编程新手,尤其是 Python.我正在尝试制作一个将华氏度转换为摄氏度的应用程序,但我不知道如何使程序保持打开状态.每当它到达代码的末尾时,它会在用户看到他或她的结果之前自动关闭.我使用的是 Python 2.6.

I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.

推荐答案

好吧,我猜你的意思是当你运行 python 文件时 Windows 为你打开的终端关闭得太快了.您可以在程序退出之前添加 raw_input('Press Enter to exit') .它告诉 Python 在退出之前等待输入.

Well, I guess you mean the terminal that Windows opens for you when you run a python file is closed too fast. You can add raw_input('Press Enter to exit') right before your program would exit. It tells Python to wait for input before exiting.

这篇关于如何防止我的 Python 应用程序在到达代码末尾时自动关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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