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

前端 未结 3 1365
离开以前
离开以前 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:35

    When I had this happen, it only happened to the very first line of my CSV, both reading and writing. For what I was doing, I just made a "sacrificial" entry at the first location so that those charatcers would get added to my sacrifical entry and not any of the ones I cared about. Definitley not a robust solution but was quick and worked for my purposes.

提交回复
热议问题