Python字符串与列表的互换
由列表转为字符串:
''.join(list)
示例:
a = ['a1', '32']
print(''.join(a)) #注意字符串为空字符串
>>>a132
由字符串转为列表:
示例:
str1 = "hi hello world"
print(str1.split(" "))
输出:
['hi', 'hello', 'world']
由列表转为字符串:
''.join(list)
示例:
a = ['a1', '32']
print(''.join(a)) #注意字符串为空字符串
>>>a132
由字符串转为列表:
示例:
str1 = "hi hello world"
print(str1.split(" "))
输出:
['hi', 'hello', 'world']
相关推荐
嵌入式的小白:很多面试,面试前不会去打扰cto的,但一般cto不会在这些小事上刷人,只能说这个cto比较操心,啥重要不重要,紧急不紧急的,估计都会过问,平淡看待吧