name=Entry()
x=name.get()
我有print(int(x))
,但出现以下错误。
Traceback (most recent call last):
File "G:/Coding/Python/first-hit/Mangal's CAFE.py", line 228, in <module>
print(int(x))
ValueError: invalid literal for int() with base 10: ''
int()
会给您带来错误的原因。我会先强制验证条目输入,然后再强制转换为int()
(例如,如果条目为空,则传递0。)>问候