Check whether string is in CSV

后端 未结 4 1352
死守一世寂寞
死守一世寂寞 2021-02-01 19:23

I want to search a CSV file and print either True or False, depending on whether or not I found the string. However, I\'m running into the problem wher

4条回答
  •  情深已故
    2021-02-01 19:51

    import csv
    scoresList=[]
    with open ("playerScores_v2.txt") as csvfile:
               scores=csv.reader(csvfile, delimiter= ",")
               for row in scores:
                  scoresList.append(row)
    
    
    playername=input("Enter the player name you would like the score for:")
    print("{0:40} {1:10} {2:10}".format("Name","Level","Score"))
    
    for i in range(0,len(scoresList)):
       print("{0:40} {1:10} {2:10}".format(scoresList[i] [0],scoresList[i] [1], scoresList[i] [2]))
    

提交回复
热议问题