Home > Backend Development > Python Tutorial > python 简易计算器程序,代码就几行

python 简易计算器程序,代码就几行

WBOY
Release: 2016-06-06 11:26:52
Original
3223 people have browsed it

代码:

代码如下:


import os
while True:
dynamic = input('输入计算表达式:')
if dynamic != 'cls':
try:
result = eval(dynamic)
print('计算结果:'+str(result))
except:
print('计算表达式输入有误!')
else:
command = 'cls'
os.system(command)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template