Why does my Python code print the extra characters “” when reading from a text file?

前端 未结 3 1357
离开以前
离开以前 2020-12-09 08:00
try:
    data=open(\'info.txt\')
    for each_line in data:
        try:
            (role,line_spoken)=each_line.split(\':\',1)
            print(role,end=\'\')
            


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-09 08:48

    I had a very similar problem when dealing with excel csv files. Initially I had saved my file from the drop down choices as a .csv utf-8(comma delimited) file. Then I saved it as just a .csv(comma delimited) file and all was well. Perhaps there might be something similar issue with a .txt file

提交回复
热议问题