方法一,使用[::-1]:

Python天天美味(8) - 字符串中的字符倒转(转)= 'python'
Python天天美味(8) - 字符串中的字符倒转(转)
print s[::-1]

 

方法二,使用reverse()方法:

Python天天美味(8) - 字符串中的字符倒转(转)= list(s)
Python天天美味(8) - 字符串中的字符倒转(转)l.reverse()
Python天天美味(8) - 字符串中的字符倒转(转)
print ''.join(l)


输出结果:
nohtyp
nohtyp

相关文章:

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