我收到第 10 行代码的错误,我在其中调用条目字符串值,感谢任何帮助,并提前感谢您的帮助。这是整个错误,以防万一:
File "c:\Users\(MY NAME)\OneDrive\Code\(MY NAME).py", line 38, in verify_license_key
url = f"https://api.gumroad.com/v2/licenses/verify?product_permalink=ewaqb&license_key={user_license_key.get()}&increment_uses_count=true"
AttributeError: 'NoneType' object has no attribute 'get'
def verify_license_key():
verify_license_window.update()
os.chdir("C:\ProgramData")
with open("verify.txt", "r") as f:
contents = f.read()
verify_license_window.update()
if contents != "CYAmS$#Rr6fM$AKR9FS@#tXMetqNkzL3HCDYry!j":
verify_license_window.update()
f.close()
url = f"https://api.gumroad.com/v2/licenses/verify?product_permalink=ewaqb&license_key={user_license_key.get()}&increment_uses_count=true"
params = {}
r = requests.post(url = url, params = params)
result = r.json()
usesAmount = int(result['uses'])
verify_license_window.update()
if usesAmount == 1:
with open("verify.txt", "w") as f:
verify_license_window.update()
f.write("CYAmS$#Rr6fM$AKR9FS@#tXMetqNkzL3HCDYry!j")
f.close()
verify_license_window.update()
change_status_verify("Confirmed")
verify_license_window.after(1000)
verify_license_window.update()
change_status_verify("Closing in 1 Second")
verify_license_window.after(1000)
verify_license_window.update()
verify_license_window.destroy()
elif contents == "CYAmS$#Rr6fM$AKR9FS@#tXMetqNkzL3HCDYry!j":
f.close()
verify_license_window.update()
change_status_verify("Program Already Verified")
verify_license_window.after(1000)
verify_license_window.update()
change_status_verify("Closing In 1 Second")
verify_license_window.after(1000)
verify_license_window.destroy()
verify_license_window = Tk()
#settings
verify_license_window.minsize(300,200)
verify_license_window.maxsize(300,200)
verify_license_window.title("Verify License Key")
#button
Button(verify_license_window, padx=12, pady=12, text="Confirm",
command=verify_license_key).place(x=112, y=100)
#label
Label(verify_license_window, width=17 ,text="Enter License Key Here:").place(x=25,y=25)
#entry
user_license_key = Entry(verify_license_window, width=40).place(x=20,y=50)
verify_license_window.mainloop()
答案 0 :(得分:1)
此错误发生在 user_license_key.get()
。 user_license_key
是这里的 None。请尝试打印出来并检查它的值或类型。如果 user_license_key
为 none,则您必须在此字段中提供适当的值。