x = 5 print(isinstance(x, int)) # True,x是int类型的对象 y = "Hello" print(isinstance(y, str)) # True,y是str类型的对象 z = [1, 2, 3] print(isinstance(z, list)) # True,z是list类型的对象 a = 3.14 print(isinstance(a, (int, float))) # True,a是int或float类型的对象 b = {"name": "John", "age": 25} print(isinstance(b, dict)) # True,b是dict类型的对象 c = None print(isinstance(c, type(None))) # True,c是None类型的对象
标签:None,函数,检查,int,类型,print,isinstance,True From: https://www.cnblogs.com/haha1988/p/17603317.html