这是我的代码,运行它时收到以下错误消息:
C:\ Users \ BeleggulWorldSeries.txt
错误是:“ fileName”
I / O操作失败。我尝试读取文件,但无法读取。您确定该文件存在吗?如果确实存在,您是否指定了正确的目录/文件夹? 请检查C:\ Users \ Beleggul \ Downloads \ assignment.py
的第5行
def main():
fileName = getMediaPath("WorldSeries.txt")
print(fileName)
file = open("fileName","r")
team = file.readLines()
dict = dict()
winningTeam = 0
for year in range(1903, 2019):
dict.add(year, team[winningTeam])
winningTeam = winningTeam + 1
print(dict.get(1903))