项目中可能会以某个元素的类型作为判断条件,以下是简单两种判断方式
>>> files = ["001.txt","002.conf","003.sh"]
>>> type(files)
<type 'list'>
2.isinstance是Python中的一个内建函数
用法:isinstance(object, classinfo)
>>> files = ["001.txt","002.conf","003.sh"]
>>> isinstance(files,list)
True
初入python,如有问题,请多指教