一种较为简单的方式是在代码开头申明,申明如下:
try:
raw_input
except NameError:
raw_input = input
以及如下的方法
try:
with open('diseases.db.json','r',encoding='utf-8') as indata: #python3
all_diseases = json.load(indata,strict=False) #python3
except:
with open('diseases.db.json','r') as indata:
all_diseases = json.load(indata)