file = open('Names.txt', 'r')
for lines in file:
names = lines.split()
names_list = [item.strip(',') for item in names]
reformattedName = (names_list[1:]+names_list[0])
print(reformattedName)
这就是我到目前为止所拥有的。
文本文件为:
Neuman, Alfred E.
Stevenson, Robert Lewis
Lewis, C.S.
Doe, Jane
Bush, George Herbert Walker
我试图重新排列它看起来像:
Alfred E. Nueman
Robert Lewis Stevenson
C.S. Lewis
Jane Doe
George Herbert Walker Bush