#处理异常
##使用try-except代码块
try:
print(5/0)
except ZeroDivisionError:
print("You can't divide by zero!")
##使用else输出正确结果
print("Division:")
print("Enter 'q' to quit.")
while True:
first_number=input("\nFirst number: ")
if first_number == 'q':
break
second_number=input("\nSecond number: ")
try:
answer=int(first_number)/int(second_number)
except ZeroDivisionError:
print("You can't divide by 0!")
else:
print(answer)
print("Enter 'q' to quit.")
#存储数据
import json
#json.dump()与json.load()