1 列表转换成字符串,用join()方法:
>>> str = ['1','2','4']
>>> print(''.join(str))
124
2 字符串转换成列表,用split()方法:
>>> str = 'Hello,World!'
>>> print(str.split(','))
['Hello', 'World!']
这两个方法的具体用法在https://blog.csdn.net/Yolandera/article/details/79888935
本文介绍了如何使用Python中的join()方法将列表转换为字符串,以及如何使用split()方法将字符串转换为列表。这两种方法非常实用,能够帮助程序员高效地进行数据格式转换。
1 列表转换成字符串,用join()方法:
>>> str = ['1','2','4']
>>> print(''.join(str))
124
2 字符串转换成列表,用split()方法:
>>> str = 'Hello,World!'
>>> print(str.split(','))
['Hello', 'World!']
这两个方法的具体用法在https://blog.csdn.net/Yolandera/article/details/79888935
2180

被折叠的 条评论
为什么被折叠?
