2024-03-29 08:00:32 发布
网友
实际上,^{}函数接受一个对象并返回它的类型。请尝试以下代码:
for item in [1,2,3, 'string', None]: print type(item)
输出:
<type 'int'> <type 'int'> <type 'int'> <type 'str'> <type 'NoneType'>
ls = [type(item) for item in list_of_items] print(ls)
下面是我将如何使用^{}来完成它。
myList = [1,1.0,"moo"] #init the array for i in myList: print(type(i)) #loop and print the type
实际上,^{} 函数接受一个对象并返回它的类型。请尝试以下代码:
输出:
下面是我将如何使用^{} 来完成它。
相关问题 更多 >
编程相关推荐