Python List 和Str 的相互转换
2022-03-25 本文已影响0人
JP0001
list==》str
list1=['two','three']
print(''.join(list1))# list 包含int 的话这个就不能使用 =>twothree
list2=['two',222,'three']
print(''.join([str(i) for i in list2]))# list 包含int 的话这个就不能使用 => two222three
mystr='asdfasdfasdfasdfs'
list1 = list(mystr)
print(list1)# ['a', 's', 'd', 'f', 'a', 's', 'd', 'f', 'a', 's', 'd', 'f', 'a', 's', 'd', 'f', 's']