Here is my code..try:
    data=open('info.txt')
    for each_line in data:
        try:
            (role,line_spoken)=each_line.split(':',1)
            print(role,end='')
            print(' said: ',end='')
            print(line_spoken,end='')
        except ValueError:
            print(each_line)
    data.close()
except IOError:
     print("File is missing")The actual output is 
Man said:  Is this the right room for an argument?
Other Man said:  I've told you once.
Man said:  No you haven't!
Other Man said:  Yes I have.The characters  ""  got added to the contents of 
my file in the beginning. Later identified it as a encoding problem. I cleared 
the problem by adding the encoding arguments when opening the file( 
data=open('info.txt',encoding='utf-8-sig')).Now my question is each time do I 
have to make this change or is there away to make this encoding a default one?  
                                         
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to