Ai
1 Star 4 Fork 0

TRG PE/scratch-detect

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
ini.py 607 Bytes
Copy Edit Raw Blame History
Alex_Kwan authored 2025-04-09 11:08 +08:00 . reload at pycharm2021
import configparser
# 创建一个ConfigParser对象
config = configparser.ConfigParser()
# 添加一个section(类似分组的概念)
config['DEFAULT'] = {'debug': 'False', 'log_level': 'INFO'}
config['Database'] = {'host': 'localhost', 'port': '5432', 'user': 'admin', 'password': '123456'}
# 将配置写入到文件中,这里假设保存为config.ini
with open('./config/config.ini', 'w') as configfile:
config.write(configfile)
# 从文件中读取配置
config.read('config.ini')
# 获取特定section下的参数
print(config['Database']['host'])
print(config['DEFAULT']['log_level'])
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/trgtokai/scratch-detect.git
git@gitee.com:trgtokai/scratch-detect.git
trgtokai
scratch-detect
scratch-detect
master

Search