dbfile = open(dbfilename, 'w')
for key in db:
print(key, file=dbfile)
in the above code,how should i write in python 2 for line 3.when i try in python 3 i get no errors but in python 2 i get errors
dbfile = open(dbfilename, 'w')
for key in db:
print(key, file=dbfile)
in the above code,how should i write in python 2 for line 3.when i try in python 3 i get no errors but in python 2 i get errors
You would normally do:
dbfile.write(key)
Python 3 might have added the file=
option but I don’t use it. I use the file api https://docs.python.org/3/library/io.html#module-io