#!/usr/bin/env python
from ConfigParser import ConfigParser;
def GetIniString(strFile, strSection, strKey):
strNullRet = ""
if (not os.path.exists(strFile)) or (not strSection) or (not strKey):
return strNullRet
cfg = ConfigParser()
try:
cfg.read(strFile)
if not cfg.has_section(strSection):
return strNullRet
strVal = cfg.get(strSection, strKey)
except:
return strNullRet
return strVal
def SetIniString(strFile, strSection, strKey, strVal):
bRet = False;
if (not strFile) or (not strSection) or (not strKey) or (not strVal):
return False;
cfg = ConfigParser();
try:
cfg.read(strFile);
if not cfg.has_section(strSection):
cfg.add_section(strSection);
cfg.set(strSection, strKey, strVal);
cfg.write(open(strFile, 'w'));
bRet = True;
except:
return False;
return bRet
SetIniString("./a.txt", "a", "b", "c");
分享到:
相关推荐
python urllib or requests模块模拟浏览器获取网页内容
python configparser类获取.ini文件配置内容
Python用WMI模块获取Windows系统的硬件信息:硬盘分区、使用情况,内存大小,CPU型号,当前运行的进程,自启动程序及位置,系统的版本等信息。 本文实例讲述了python使用wmi模块获取windows下的系统信息 监控系统 ...
基于python的windows窗口打包exe工具基于python的windows窗口打包exe工具基于python的windows窗口打包exe工具基于python的windows窗口打包exe工具基于python的windows窗口打包exe工具基于python的windows窗口打包exe...
python爬虫案例获取歌曲python爬虫案例获取歌曲python爬虫案例获取歌曲python爬虫案例获取歌曲python爬虫案例获取歌曲python爬虫案例获取歌曲python爬虫案例获取歌曲python爬虫案例获取歌曲python爬虫案例获取歌曲...
自行编译的 python 3.7.11 windows install 64bit 安装包
python使用ip获取经纬度信息
python使用requests模拟登录带验证码的专利网站demo
python模拟鼠标操作
利用简易的字符在黑屏终端来模拟平时下载中看到的下载进度条,显示时间,完成百分比等功能,简单好玩的小程序。
Python 模拟http服务端, 客户端
Python 3.12.0 Windows 64位版安装程序
req_header = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11", "Accept":"text/html;q=0.9,*/*;q=0.8", "Accept-Charset":"ISO-
python模拟网页下拉实现,进入网页后,实现右侧下拉条自动滚动
主要介绍了Python模拟鼠标点击实现方法(将通过实例自动化模拟在360浏览器中自动搜索python),需要的朋友可以参考下
python在windows锁屏的代码,只要环境安装好了,切换到脚本目录下,就可以锁屏你的计算机,请多多支持,谢谢!
用于实时获取微信聊天信息,支持最新版微信PC客户端3.7以上版本. 基于Python3.6及以上版本
python-opencv获取二值图像轮廓及中心点坐标代码: groundtruth = cv2.imread(groundtruth_path)[:, :, 0] h1, w1 = groundtruth.shape contours, cnt = cv2.findContours(groundtruth.copy(), cv2.RETR_EXTERNAL, ...
iPhone获取手机型号Python代码