今天我们讲解:
>>> x = 1
>>> if not isinstance (x, int or float or bool or complex or str or list or dict or set or tuple):
... x = 0
...
>>>
if not isinstance (x,str):
x= str(x)
if not isinstance(x, list):
x= [x]
#这样的好处是代码更加健壮
isinstance函数功能:判断一个对象,如x是否是一个已知的类型,如str、list
isinstance (x,int)



