I'm having strange issues with json. The following program opens a file, imports a dictionary, adds entries, and saves the dictionary again. When the program is run a second time, a letter "u" has been added in front of every key and every value of the dictionary. These are not cumulative; running the program multiple times does not add multiple "u"s.
import json
file1 = open('phonebook.txt', 'r+')
phonebook = json.load(file1)
print phonebook
while(True):
name = raw_input("Name?")
if name == "":
break
number = raw_input("Number?")
phonebook[name] = number
file1.close()
file1 = open('phonebook.txt', 'w')
json.dump(phonebook, file1)
print phonebook
Incidentally, an unrelated peculiarity: I get error messages unless I close and reopen the file in write mode. I don't know why this is happening.