I have a dictionary and am trying to write it to a file.
exDict = {1:1, 2:2, 3:3} with open(\'file.txt\', \'r\') as file: file.write(exDict)
The probelm with your first code block was that you were opening the file as 'r' even though you wanted to write to it using 'w'
'w'
with open('/Users/your/path/foo','w') as data: data.write(str(dictionary))