我正在处理文件atm。我循环文件并打印出其内容。
fileO = open("PlayerProfile.txt", "r")
fileData = fileO.read()
fileSplit = fileData.split('\n')
for Player in fileSplit:
SplitProfile = Player.split(',')
print SplitProfile
print SplitProfile[1]
Print SplitProfile [1]超出范围????
输出
Traceback (most recent call last):
['Person1', 'apple']
File "C:/Users/marcus/Desktop/Python/Overwatch/Main.py", line 15, in <module>
apple
print SplitProfile[1]
['Person2', 'orange']
IndexError: list index out of range
orange
['']
我很感激任何帮助,解释为什么我找不到有帮助的答案。