Python 2.7 Python,将一些行向下反转为向上
我不知道怎么做:Python 2.7 Python,将一些行向下反转为向上,python-2.7,Python 2.7,我不知道怎么做: a b c d e 1 a b c d e 2 a b c d e 3 ... a b c d e n 需要: a b c d e n .... a b c d e 3 a b c d e 2 a b c d e 1 我试过这样的方法: newcontent=codecs.encode(content,'utf_8','replace') for i in reversed(newcontent): newcontent.append(i) print ne
a b c d e 1
a b c d e 2
a b c d e 3
...
a b c d e n
需要:
a b c d e n
....
a b c d e 3
a b c d e 2
a b c d e 1
我试过这样的方法:
newcontent=codecs.encode(content,'utf_8','replace')
for i in reversed(newcontent):
newcontent.append(i)
print newcontent
运行代码时会得到什么输出?将所有内容都放在一个列表中,然后执行:
my_list[:-1]
或迭代reversed(my_list)
。