I have a program that updates information to an ini file but when I try to do this I get this error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "C:\Users\Public\Documents\Programming\Math-Bot\Math-Bot.py", line 106, in check
config.write()
TypeError: write() missing 1 required positional argument: 'fp'
But I can't seem to find the what I need to do,
this is my code to write to the config file:
user = 'default'
config = configparser.ConfigParser()
config.read('settings.ini')
config[user]['wrong'] = str( int(config[user]['wrong']) + 1 )
config.write()
and this is the config file:
[default]
wrong=0
Any Ideas I really need help!
Thanks In Advance!
As the documentation says:
write
(fileobject, space_around_delimiters=True)
Write a representation of the configuration to the specified file object, which must be opened in text mode (accepting strings).
So you problem is, you are missing the file-object argument from the write method:
config = configparser.ConfigParser()
# do some configuration here
with open('settings.ini', 'w') as settings:
config.write(settings) # write to a file