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

Python天天美味(7) - 连接字符串(join %)= ['a''b''c''d']
Python天天美味(7) - 连接字符串(join %)
print ''.join(s)
Python天天美味(7) - 连接字符串(join %)
print '-'.join(s)

输出结果:
abcd
a-b-c-d

使用 % 连接多个变量

Python天天美味(7) - 连接字符串(join %)= 'hello'
Python天天美味(7) - 连接字符串(join %)
= 'python'
Python天天美味(7) - 连接字符串(join %)
= 1
Python天天美味(7) - 连接字符串(join %)
print '%s %s %s %s' % (a, b, c, s)

输出结果:

hello python 1 ['a', 'b', 'c', 'd']


Python 天天美味系列(总)

Python 天天美味(5) - ljust rjust center  

Python 天天美味(6) - strip lstrip rstrip  

Python 天天美味(7) - 连接字符串(join %)  

Python 天天美味(8) - 字符串中的字符倒转

Python 天天美味(9) - translator

...

相关文章:

  • 2021-08-11
  • 2021-09-18
  • 2021-10-11
  • 2021-08-17
  • 2021-08-15
  • 2022-01-15
  • 2021-08-03
猜你喜欢
  • 2021-06-12
  • 2021-07-27
  • 2021-07-28
  • 2021-07-22
  • 2022-01-03
  • 2021-11-04
  • 2021-07-27
相关资源
相似解决方案