calculator.py
原始文件
while True:
try:
opr = input("calculator> ")
exec(f'ans = {opr}')
print(ans)
except KeyboardInterrupt:
print()
quit()
1 | while True: |
2 | try: |
3 | opr = input("calculator> ") |
4 | exec(f'ans = {opr}') |
5 | print(ans) |
6 | except KeyboardInterrupt: |
7 | print() |
8 | quit() |
9 |