Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 Python,将一些行向下反转为向上_Python 2.7 - Fatal编程技术网

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)