我不明白为什么会收到错误AttributeError:模块'json'没有属性'load'。
当我执行JSON模块的目录查找时,没有看到作为选项引用的“ load”或“ loads”属性。知道为什么吗?我正在使用sublime 3和python 3.6。另外,请参阅下面的python代码以及JSON文件。预先感谢您的帮助。
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']
import json
def search():
search_term = input("Enter search term: ")
with open("dictionary3.json") as data:
term_data = json.load(data)
print("{} - {}".format(search_term, term_data[search_term]))
response = input("Search terms or add term\n Enter Search or Write: ")
if response.casefold() == "search":
search()
elif response.casefold() == "write":
print("Write")
else:
print("Program Failed")
{"car" : "has wheels"}