use*_*745 2 python variables tkinter
我尝试做:
def create_l():
if 'l' in globals():
l.destroy()
l = Listbox(root)
Run Code Online (Sandbox Code Playgroud)
这工作正常,但它返回一个语法警告:
Warning (from warnings module):
File "C:\Users\User\Desktop\l.py", line 4
l = Listbox(root)
SyntaxWarning: name 'l' is used prior to global declaration
Run Code Online (Sandbox Code Playgroud)
我只是想知道是否有办法在没有语法警告的情况下做到这一点。
Spl*_*xyy 10
使用del关键字
if 'l' in globals():
del l
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7580 次 |
| 最近记录: |