Error: Getting symbols in python output -
#i wrote following code making text editor. print "this simple text editor" sys import argv script, name = argv print "you have selected file : %s" %name print "opening file...." t = open(name, 'r+') print "the contents of file are" print t.read() f = open(name, 'w+') print "now truncate file , empty of it's contents" f.truncate() print "now let write our file\n" x = raw_input('what want write\n') #works fine till here f.write(x) print "now read our file again" print f.read() print "and close file" f.close()
after promp write in file, script goes awry , produces strange symbols instead of typed text. please help
you need close , re-open file.
print "this simple text editor" sys import argv script, name = argv print "you have selected file : %s" %name print "opening file...." t = open(name, 'r+') print "the contents of file are" print t.read() t.close() ########## f = open(name, 'w+') print "now truncate file , empty of it's contents" f.truncate() print "now let write our file\n" x = raw_input('what want write\n') #works fine till here f.write(x) f.close() ########## f = open(name, 'r+') ########## print "now read our file again" print f.read() print "and close file" f.close()
Comments
Post a Comment