字符串 转换成 列表
Python split()方法
str = "Line1-abcdef \nLine2-abc \nLine4-abcd"; print str.split( ); # 以空格为分隔符,包含 \n print str.split(' ', 1 ); # 以空格为分隔符,分隔成两个以上实例输出结果如下:
['Line1-abcdef', 'Line2-abc', 'Line4-abcd']
['Line1-abcdef', '\nLine2-abc \nLine4-abcd']
https://www.runoob.com/python/att-string-split.html
列表 转换成 字符串
Python join()方法
x = "-"; y = ("a", "b", "c"); # 字符串序列 print x.join( y );以上实例输出结果如下:
a-b-c
https://www.runoob.com/python/att-string-join.html
标签:abcd,abc,Line1,列表,split,字符串,格式,abcdef From: https://www.cnblogs.com/xudacongming/p/16662814.html