Jul-27-2018, 08:22 PM
All,
I need some assistance with my Python Code. While I consider myself a intermediate programmer, I tend to struggle with Python code coming from primarily a Visual Basic with Applications background.
I am sure this is something simple that I am missing, but if someone could point me in the right direction, I think I may get it from there.
I need some assistance with my Python Code. While I consider myself a intermediate programmer, I tend to struggle with Python code coming from primarily a Visual Basic with Applications background.
import configparser config = configparser.ConfigParser() config.read('G:\\WINDOWS\\Gauge_Example.ini') # Check to see if the section exists if config.has_section('PROPERTY_ORDER'): print('Section exists!') else: config.add_section('PROPERTY_ORDER') with open(strFile, 'a') as configfile: config.write(configfile)What I am attempting to do is read the INI file and look for a section called 'PROPERTY_ORDER'. If I don't find it, I want to add this section. The way I am doing it now is it wants to append the entire contents of the file (again) plus my added section, which I do not want.
I am sure this is something simple that I am missing, but if someone could point me in the right direction, I think I may get it from there.