1. 连接 join()
In [2]: a = '...'.join(['1', '2', '3'])
In [3]: a
Out[3]: '1...2...3'
- a = '...'.join([1,2,3])会报错:
TypeError: sequence item 0: expected string, int found
应改为In [6]: a = '...'.join([str(x) for x in [1, 2, 3]]) In [7]: a Out[7]: '1...2...3'
2. 分隔split()
In [9]: b = '1...2...3'.split('...')
In [10]: b
Out[10]: ['1', '2', '3']