我需要确定一个给定的Python变量是否是本地类型的实例:
或者这是唯一的方法:
str
、int
、float
、bool
、list
、dict
等等。有没有更优雅的方法来完成它?或者这是唯一的方法:
if myvar in (str, int, float, bool):
# do something