from tkinter import *
from tkinter import ttk
root = Tk()
root.geometry("600x400")
root.resizable(False, False)
def nameLength(event):
str(input)
length = input.split()
length1 = len(garums)
myLabel = Label(root, text=length1.get()).pack( )
choice = ("Word count", "Delete symbol", "Change 1st word with last word")
options = StringVar()
options.set("Choose an option")
input = Entry(root)
input.pack()
menu = OptionMenu(root, options, *choice, command=nameLength)
menu.pack(pady=20)
root.mainloop()
當我運行我的代碼時,我往往會收到一條錯誤訊息,指出 AttributeError: 'Entry' object has no attribute 'split'
我試過用谷歌搜索它,似乎沒有人和我有同樣的問題。如果有人能幫助或解釋,將不勝感激!
uj5u.com熱心網友回復:
input是物件的一個??實體Entry。就像錯誤說的那樣,它沒有方法split。既然是Entry物件,就不是字串物件。您必須使用方法將字串傳入和傳出Entry物件。
input_value = input.get()
length = input_value.split()
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/413723.html
標籤:
