Python列表数据类型转换

将int型数组转换成字符串数组

#@Created on Tue Apr  2 16:10:51 2019
#@author: Hu Sai
#@email: [email protected]
list1 = [1,2,3,4]
list2 = map(str,list1)

for i in list1:
    print(i)
    print(type(i))
    
for i in list2:
    print(i)
    print(type(i))

output

1
<class 'int'>
2
<class 'int'>
3
<class 'int'>
4
<class 'int'>
1
<class 'str'>
2
<class 'str'>
3
<class 'str'>
4
<class 'str'>

你可能感兴趣的:(程序猿)