code
#利用reverse方法
l = list(s)
l.reverse()
result = "".join(l)
#利用reversed()方法 def str_num(num): print num[::-1] print "".join(reversed(num)) print reversed(num),type(reversed(num)) str_num(num)
#递归思想
num = 'chejibadan' def diGui(num): if len(num)<=1: return num return diGui(num[1:])+num[0] result = diGui(num) print result
#利用循环思想
def ce(num):
new_str=[]
index = len(num)
while index:
index = -1
new_str.append(num[index])
return ''.join(new_str)
参考链接