python结束程序的三种技巧
2021-03-05 14:27
标签:bsp erro cep str 注册 pytho with pen man python结束程序的三种技巧 标签:bsp erro cep str 注册 pytho with pen man 原文地址:https://www.cnblogs.com/2722127842qq-123/p/14324588.html1. break
2.exit(0)
3.sys.exit(0)
import file_manager
import sys
def start():
# try:
# with open(‘file/welcome.txt‘,‘r‘,encoding=‘utf8‘) as f:
# content = f.read()
# while True:
# input(content)
# except FileNotFoundError:
# print(‘文件未找到!‘)
content = file_manager.read_file(‘welcome.txt‘)
# file_manager.BASE_DIR = ‘./xxx/‘
# content = file_manager.read_file(‘sss.txt‘)
while True:
operator = input(content + ‘\n请输入(1-3:‘)
if operator == ‘1‘:
print(‘注册‘)
elif operator == ‘2‘:
print(‘登录‘)
elif operator == ‘3‘:
print(‘退出‘)
# break # 结束循环
# exit(0) # 退出整个程序
sys.exit(0) # 退出整个程序
else:
print(‘输入有误!‘)
if __name__ == ‘__main__‘:
start()
上一篇:Java终止线程的三种方式
下一篇:ArcGIS Python拱形面