python3----连接字符串数组(join)

join 方法用于连接字符串数组

1 s = ['a', 'b', 'c', 'd']
2 print(''.join(s))
3 print('-'.join(s))
4 
5 results:
6 
7 abcd
8 a-b-c-d

使用 % 连接多个变量

1 a = 'hello'
2 b = 'python'
3 c = 1
4 print('%s %s %s %s' % (a, b, c, s))
5 
6 results:
7 
8 hello python 1 ['a', 'b', 'c', 'd']
原文地址:https://www.cnblogs.com/jonm/p/8270385.html