python中反转字符串可以说是易如反掌,估计再没有语言比python的字符串反转方式更简单了,下面的代码对数组里的所有元素进行反转
#!/usr/bin/env python # # [代码名字: Reversing strings] # [代码分类: Python Core] # [代码描述: How to reverse the contents of a string] # [代码作者: Scott Ferguson <scottwferg@gmail.com>] # [代码协议: GPL] text = ['Hello', 'world', 'Go hang a salami I\'m a lasagna hog'] for word in text: print word[::-1]