Python 变量类型判断

方法一:

a = {}
if type(a).__name__ == 'dict':

 

方法二:

a = {}
if type(a) == dict:
if type(a) == int:
if type(a) == str:
if type(a) == list:

 

posted @ 2022-03-13 22:05  rmticocean  阅读(128)  评论(0)    收藏  举报