python输入Hello+world怎么输出dlrow+olleh?

Python057

python输入Hello+world怎么输出dlrow+olleh?,第1张

使用切片[::-1]逆序输出字符串即可,python代码为:

s=input()

print(s[::-1])

运行结果如下:

可见成功将输入的字符串逆序输出

s= str(input("请输入字符串s=")) #输入a b c e f gh

s1=s.split(" ")

print(s1)   #打印['a', 'b', 'c', 'e', 'f', 'gh']

print(''.join(s1)[::-1])  #打印 hgfecba

print(' '.join(s1)[::-1]) #打印 hg f e c b a

在python 3.5运行完全满足题的要求。