如何不使用try
, except
语句检查是否声明了变量?
The dir()
command gives a list of all the variables in your global namespace. If your variable is x_val
, use
'x_val' in dir()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.