开发者

Delete INI section in Python

开发者 https://www.devze.com 2023-03-11 02:46 出处:网络
In python, I\'m 开发者_运维知识库using win32api to read and write INI settings as and when they are required into specific sections based on IDs.

In python, I'm 开发者_运维知识库using win32api to read and write INI settings as and when they are required into specific sections based on IDs.

Once I have finished with the section, I want to be able to delete the entire section from the INI file. How would I go about doing this using the win32api python library?


My proposal is to use native Python module for handling INI files ConfigParser. Have you tried it already? It has remove_section method that probably will work for you.


This is not a Python specific answer, but look into calling WritePrivateProfileString with the lpKeyName parameter set to NULL. With this parameter set to NULL the entire section named in lpAppName, including all entries within the section, is deleted.

0

精彩评论

暂无评论...
验证码 换一张
取 消