1
這是查看帶有高分條目列表的文本文件並將其放入列表中的代碼部分。我需要然後拆分字符串和整數。從文本文件中整數分割字符串
OutList = input("Which class score would you like to view? ").upper()
if OutList == 'A':
List = open("classA.txt").readlines()
print (List)
elif OutList == 'B':
List = open("classB.txt").readlines()
print (List)
elif OutList == 'C':
List = open("classC.txt").readlines()
print (List)
此代碼當前打印此:
['Bobby 6\n', 'Thomas 4\n']
我需要知道如何分離這些和擺脫「\ n」只是有名稱和得分打印出來的。
謝謝!完美的作品 – Shakey0198 2015-03-19 21:47:59