我试着用json和python创建一个字典,但我得到了这个错误TypeError: 'module' object is not callable
我该怎么办
from tkinter import *
from tkinter import ttk
import path
import json
data = path("json.json").()
word_list = json.loads(data)
from tkinter import *
from tkinter import ttk
import path
import json
data = path("json.json").()
word_list = json.loads(data)
class root(Tk):
def __init__(self):
super().__init__()
self.title('dictionery')
self.minsize(380, 250)
self.labels()
self.dictionary()
def labels(self):
self.Label_1 = ttk.Label(self, text='serch')
self.Label_1.grid(column=3, row= 0, padx= 55)
self.Entry_1 = Entry(self)
self.Entry_1.grid(column=3 , row = 1, padx= 50)
self.listBox = Listbox(self, height= 10, width= 40)
self.listBox.grid(column=3, row= 3, padx= 60)
self.button = ttk.Button(self, text= 'serch')
self.button.place(x= 250, y=14)
def dictionary(self):
word = self.Entry_1.get()
meanings =word_list[word]
for meaning in meanings:
self.listBox.insert(END, meaning)
window = root()
window.mainloop()
1条答案
按热度按时间fbcarpbf1#
我怀疑这个问题是由
import path
引起的,它是无效的。您实际上可能需要的是from pathlib import Path
而且
data = path("json.json").()
结尾的额外括号也是一个问题。