Python 读取写入配置文件 —— ConfigParser
Python 读取写入配置文件很方便,可使用内置的 configparser 模块;可查看源码,如博主本机地址: “C:/python27/lib/configparser.py”
Configuration file parser.
A setup file consists of sections, lead by a "[section]" header,
and followed by "name: value" entries, with continuations and such in
the style of RFC 822.
该模块支持读取类似如上格式的配置文件,如 windows 下的 .conf 及 .ini 文件等。
本章节使用如下的配置文件作为示例,可在 D 盘下新建 Pyhton_config 文件夹,创建两个文件 test.config 及 test.ini 内容及示例截图如下:
[db]
db_port = 3306
db_user = root
db_host = 127.0.0.1
db_pass = xgmtest [concurrent]
processor = 20
thread = 10
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbMAAADXCAIAAAAfnSgoAAAgAElEQVR4nO2de3AU153v+5/NP06J3D82F2qT8Jdt9lZdXyfef+QiNq647HjBvontOALJ4N0tZst2uDeJk7Lsa5xgL7AGR4g1xLX2EscGAXprNEgIGSQwGr1GD8BghJ4zesxLIM2MXiOpB+4fZ7rndPc5Pd3Tr2np961vUUPPOd09PWc++p1H/5qpu3ob82TdlfCZdHb1hmp7gs7uQI3Hj1zd6a/u9Fd2TOCu6BgXuH2M6PK2UanLWn1ku700l7aMiHy6ZVipLw/hPvXVoCqjKnz10pbhMvdIeau3os1X2T5a1TFW3Tle45lwdvmdXf7a7oCrJ3imN3SmN1R3JVx3JVx/dbL+6uTZa7fBvNE1qUcNsjfk6gm6eoLJVtflr/ZMVHWOV3aMVbSPVrSPlrf5ylq9Za3eUvcIctpvXNpapJZpbFTT2m2rr6zVR2zqSkz77SQt+qGRLPptZuCqTtWu9vjtayYJxKuTdVcnzyArIWN30NkVQK7x+Ks6k84AjjINwioyGgrH2u4AD0dERoCjDBzR9UFwRGSUwrG8zZcBHNPyUXcyWghH7WTMgI+W000jGTEm4iZisTfp2u5gbXewpiuATCOjEj7KNwjlZNQERwkZM+AjXwWRkYcjTkYejigIksIR+CiCI0/GM72hVGcFI6NGOMrwMRMyGhk5puGjKWRUBUfL6aaJjAQmE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MoJMFZARZAsBGUGmSuXdgeYSExJEgjgBGUGmajWSEZ94F2+GmZMsFZARZKroZCRC0N5k5J4t45B+Clhtk+UCMoJMFZGM0jtURA/Yk4RXchkcyJkjBMfAMZUq7jhkUG9ayndYoZ3tAjKCTFUGMaMUlDIZHCiZI+7dGxjAiwiS+eCJa8whI9zVl/UCMoJMlbbeNE8UZc99pvSOqc+VTtebzjQThORsIRNE1gvICDJVBpNRJnME6dYYUbBm1Nw0xIz2E5ARZKpMjRmF26V9crVk1C1mhHHGrBeQEWSq6GQkQk0tGWmJFfHhREkCCqxnbdI4I8xNZ72AjCBTJbeeEesKk7P5KyDjPVo6iNTOcw/V4wl5+DfQXLcBq3YoESasZ8xmARlBpgqekAWyhYCMIFMFZATZQkBGkKkCMoJsISAjyFQBGUG2EJARZKqAjCBbCMgIMlVARpAtBGQEmSogI8gWAjKCTBWQEWQLARlBpgrICLKFgIwgUwVkBNlCQEaQqQIygmwhICPIVAEZQbYQkBFkqoCMIFsIyAgyVUBGkC0EZASZKiAjyBYCMoJMFZARZAsBGUGmCsgIsoWAjCBTBWQE2UJARpCpAjKCbCEgI8hUARlBthCQEWSqgIwgWwjICDJVQEaQLfT/ASicGlZ7ua9LAAAAAElFTkSuQmCC" alt="" />
本章节就基础读取及写入配置文件进行具体的说明。
基础读取配置文件
- -read(filename) 直接读取文件内容
- -sections() 得到所有的section,并以列表的形式返回
- -options(section) 得到该section的所有option
- -items(section) 得到该section的所有键值对
- -get(section,option) 得到section中option的值,返回为string类型
- -getint(section,option) 得到section中option的值,返回为int类型,还有相应的getboolean()和getfloat() 函数。
# !/usr/bin/env python
# -*- coding:utf-8 -*- import ConfigParser
import os os.chdir("D:\\Python_config") cf = ConfigParser.ConfigParser() # cf.read("test.ini")
cf.read("test.conf") #return all section
secs = cf.sections()
print 'sections:', secs, type(secs)
opts = cf.options("db")
print 'options:', opts, type(opts)
kvs = cf.items("db")
print 'db:', kvs #read by type
db_host = cf.get("db", "db_host")
db_port = cf.getint("db", "db_port")
db_user = cf.get("db", "db_user")
db_pass = cf.get("db", "db_pass") #read int
threads = cf.getint("concurrent", "thread")
processors = cf.getint("concurrent", "processor")
print "db_host:", db_host
print "db_port:", db_port
print "db_user:", db_user
print "db_pass:", db_pass
print "thread:", threads
print "processor:", processors
ConfigParser
示例代码详见上方,解析如下:
需要实例化为 ConfigParser 对象 cf = ConfigParser.ConfigParser() ;读取文件 cf.read("test.conf")
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAANEAAACECAIAAACBG1n8AAAI5ElEQVR4nO2dO7LsJhCG2ZZmQdqOZgnegTNtwLFTB9Z1ZtctO3F07cC3Sg5Gjwa6G5BQM4//K4IzDEIM+sWraY778vUbAoJlcM1LgPBpwX35+g8CgmVwv/35Lw2zc81DUCSENwvu97//o2F2YYxxaF4AhKuD+/nXv2iYXRhjHJoXAOHq4H748ScaZhfGGIfmBUC4Orhf/vj2/fv3ecO5/e/pfnMrt/s0R0z3m+vHeZ7nsXfLX3EKNYsIWgDwjiQ1xwmJSSBpbmPsoTkwzzM0B+w5oLm9u+zvgea2r2J5QXNgoVhzY78rauydI5rbvqBpyHXQHJjncs35fajUt073W6gwaA4sFGouEBM0B8q5RnPMjAKaAwulfet0v21yeozhyHhuiadpNqA5sHBg3vqQmlvnqZvmbvd7L6/+QnNg4dz6XAHQHFg4Z/tKA9sXCFE114TmBQAXk6e5aehybVznSwTNvTmc5pqHJmxTI+e/VVI8/YYz1ix0w6ExyTsTaY7Fsp0TMbv12PNS8eKnoVs/kD+XT62q6DVQNDcN3foaD4Hmtq+Sb/Ej/fbe0/R7/uQZ8fnTtoZvWWria4iPF9fAG76Ur4KoOfpSR7Z8IoWE6ui6MU3vPVfSNND8p6GjuVs9zb1Rl+ODNPuveXzBvmNgQdJcYD8V+lapRdDy6YYpvnBLpgirQHO0Cc0fWa1KCRMy8WFZvPLvBhl0sxyC5gJNVNec+szOa+4cGeM5sZ0Lrh17NHUR5zSXloGQ/inbOe/yRO8q1UP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89/Qf20n4Co/Ec5q2GqOtzjF97seZmyUC/Z94NI918sn3xmAdfsFYitIpYn7MBPjjAGmgOWAPNAWugOWANNAesgeaANdAcsAaaA9ZAc8AaaA5YA80Ba/4HVB3XhYkA/xwAAAAASUVORK5CYII=" alt="" /> secs = cf.sections() 获取sections,返回list aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAAAZCAIAAAAt9LlKAAAELElEQVR4nO2b0aGrIAyGmYuBmMcR7hQs4zDnPlg5EEICAavt+b+3FgkhCb+IrfsBAAAwgfsHAABgAne3jgMAwGcDGQUAgCkgowAAMAVkFAAAprhfRjfv/Lbf7QUA4Fl8kDJARi3sm3cHITbalDnlF8XQ0aHbsoXrLP812pFMNfOHotyMxlHySjSuUoYLqv1iGd0377drh7iDffPNJLySVOurZEQyOG55mOssfxlqPWuR7Eq0xuady9147Cp7SzRYowavNm9fAZBRC2L6Y3BllXcY6aunXsvjXGf5u9DrWYnkpHAcCkAtPHeVXRsNwajNq2OTbNBS9xrYJUIIhaHf/Tc/RNEetjSHst+5g2c78qEsvMouefULMbuAuiXOKDNiTKKc/tZtLXfKbzsjo1nMWPszN0yZtuVWfqspjeaoYTk9cpUj1MZdiJmN5JXcKtSz4rNaz2okX9OxCge7+GWvsvnv5/DnxNJREinLtnVL5ZmiMaQM+epekiOLlrqj22+nGHIb++YrTc0+78SfKtMd90k+lDEUMWQHKoojtyHNqDBwjYzGwNg9fEwfyfHMvnnviymyB0Os5SXwluX8zuRItlyVTR3vc8Wc38cYO1qVelbqqque5RzZZFRZ2YJX9RRiyG9R3tOyzGtSjFWv5+ZoCCIrre7pHCWz/Zlyos1Yb+Py73RvrDLKfFeYoiktr79ObXJfhgZgIpl7SUS21eXNyHGcyZGSoU4ZbYen0arUs1ZXCx6fhyvn2HnJhSB6ddzs0sdcG8WqU2O1AKuMiiFcd8TBnqCwuJdjxS747Fdsnpl9sh5Vo4yyhvMv6QXURmtGi7AshioO6tnoFQdHQ4j5ncqRUjl9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GbpPQN41ZH1TawnCcSn818O9YMVSdS/UyRRPSmS6P47RRLVkyKJ+eSzb1RPKyBVRHstagLz4a//SvnBDllg8CaFCT+YO47kfD6+zRPvL7hd1dpbOYBlk6E0mrZL+NbYvuel/vf+ME8fivnBYGF0qrQO7tqEl8LKbu39CEBE/vIhXg7DX6MOnU3cArPveYn/vT9M9764H0y+8eGvuRP7hrlLSfgt12s00WI0Ug6DfKID0SnonQcbfRb43/vDvHpX3A+OXRa+YwiKkzp+kRo/RbVLlcNsPcU9GNaV5/vf+8O8elvcD54+eUMUIhmqO8WOS7VP19+O9cZOInrKeUNgjv+9P8yPjJ5E/WAsPiw7cJzygzmfOMj5UvxXsDxDMS4HTk/km1KIpBf73/vDfP9cyg9Gfy966gGa1rUNGN8iLQrvE4c5nw82o4OtZ1gOnJ5I3xq5icX+9/4w370p4AeXarTLrD+54/y7g9mYb8X0xFCTnnL69+NiXv6uekrj9UgqJhrz4rW+X6CIYb7+TfWkiGG++hXT0+MGZVPMl79EelKUpfwPvozo+IS4dxYAAAAASUVORK5CYII=" alt="" /> opts = cf.options("db") 获取db section下的 options,返回list aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAsEAAAAZCAIAAABfIWRIAAAFU0lEQVR4nO2d3YGsIAyFty4Koh6roRmLcR90lJ+QRARBPd/b7giEkwCZ4N77twAAAAAAnOevtwEAAAAAeCTIIQAAAABQAnIIAAAAAJSAHAIAAAAAJfTJISbzZ6a5y9AAAADADXzhpEMOoWWezN+KdZnPhDn5DzmraDAsuvm26xlK1uq5lpL7aGXGVuAtSvYnP999D3zq1ArIqrE6WVCj1UnXLtrP0yCHmCfTcStpxjyZrMc2j6bJBdcJ12FfRA+q51sy9JuUFHmTkk0XPmLyNqT5VpnaZMKMc9hT4xY1yE4LrJpMkxXAgxxCCxsrzuq+hD1jl5E9qJ3ved6lpMyLlOybQ7xJyc4I8704tfX4i3sY99RoqwbTaZlVa3nkzkQik0MchfvA3XuNzv/cU/Ao7/itvX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tZKOKlwXSrFpSGtL0akTikfCiWY9z8cv2Qoy0jPt3L8XErgNc9E5KR+gL7fYTHa8fbZ/W9fmMVOeYsuD9uGamDXjlWtVBw8WnWk+2ShSJlraiEb7n0FtHjfEjJUXRGMk/Eiy0jPorlONe0ULD/yGNrvobRjQMZGjD1Wdpa8TzcWJrW3WE+pOQoWj2Ym3iRZYRHtxzzSVgozjVP6Xr6J1rFnEWOCc4kx5zOSc9AjvrxmtOu72SXN5Aj6Ac15Q45AkXlHskR4T2DDrRcBwAz5AhUATkCRUCOQBGQI1DEb/aChSQhSEVJAAAAAElFTkSuQmCC" alt="" /> kvs = cf.items("db") 获取db section 下的所有键值对,返回list 如下,每个list元素为键值对元组
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA9AAAAAYCAIAAACdn4L7AAAHDUlEQVR4nO2cwaG0KgyFrcuCqMdqWL0SXgcW47+YUSGEBIQocz3fau4gSPAkRGDu5P/7fwMAAAAAAADYMCHhBgAAAAAAwA4k3AAAAAAAABiChBsAAAAAAABDkHADAAAAAABgiJ5wL/M0TdO8rNu2eXd+tmP93HKaJuezF3k3zUumptLB+y2yosze3i1/xiz3hOTS4OGmj49ekTSQ75V3tzxEqG57SnXPAdUFd7tQtw9PqW5d5lxZEKnoBWEU1Cczse36MW+pK9m7wRfG4G0R2I6rej5crHakila412U+2g0/G1Fwi8xofIdBD203W3SRdZnliFls75Vbsy17F367LnN0jVz6+Wa3aF3mtHk52kv2ss115h2qU7lfdaa0eNmrVKcOVAujxrppmpfFMYMWRTfvSNjyLm6P/q33SIyTJnVle88W4QtP87YIbNdym54vSOgnE+4wpsR4V/Za/xuOpwux1N56SluWBy8u9S5ukNZlVy+Ke2W9xPIW1ek8r7qetHnZi1T3bML9oOo8k4DSkZT7X5dva3HSqm7YRq4OfGEE3haB7Vpu0nO3hDvc1Z+XlZFpsGXGL8c3bEyoZixztulkUbWTRRzHthRpPHvjKckvp/316rj799kzW5KsLHL2tlPScj4CcqXrMscNkm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ZQ3Ydsr2QvU32wzcvepTrhNU8cZ0WT9IohYt0Jpzwa3HJTezIsUVFmllTipFldqVYJr/EFcd4nw+fJ/8GQfUH3FA0TX2Bn+syME3WgMOHO+b44W1lHFfVlp0/CvR0ueSzT7/I65vZwsZ+5pXHCzb2bKrRaJHaVNE67mtnySLadmLfSa706axps78UW0RvIpVvwm0j1V+W16pHW2nuMxjiq2+Jxdj76PVC6EUdaphcERpVoUu9Wb9WpvRK8TC3dWrzsNaoLqpzLeKQFYZxVTW4DxjpuR/voGFuWtiHJQ5wllThpUVe0t4SX+MKmzvtxwHJLlJ7LvlDiKUrPmseZQnw9iQVbbPG8LF8hxBW/fzm/txCn7Bl7hdnKNqpou/dbx4T7WQrMUIfiJi6M+D2sy1wvsF+G2+SLCjuMxiiqGxaojhZCdfa8TnVj8iZfwLwvMspjakLU83HJH0m46QtUirBVdyPDOp7lr1dGRD1K3mc0xlDdsEB1pBSqu4G3qW5MXuULmPeVTgzwjBqR9XzkqH8h4f4Voo2jx1UOAAAAAEsw7zNExzswKFmQcOfhzrSxZ4kA6AZUB+4HqgPgA3wBmIGEGwAAAAAAAEOQcAMAAAAAAGAIEm4AAAAAAAAMQcINAAAAAACAIUi4AQAAAAAAMOQfOEwLJJhU7LkAAAAASUVORK5CYII=" alt="" />
通常情况下,我们已知 section 及 option,需取出对应值,读取方式如下:
#read by type
db_host = cf.get("db", "db_host")
db_port = cf.getint("db", "db_port")
db_user = cf.get("db", "db_user")
db_pass = cf.get("db", "db_pass")
cf.get(...) 返回的会是 str 类型, getint 则返回int类型 aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAREAAABQCAIAAACxhdakAAAGCklEQVR4nO2d2YGsIBBFOy4DMh6jMRmD8X20CxRQRWnj8uacr+lmERxus8iVzwwAHj53FwDgZaAZAB9oBsAHmgHwUdTM0H0+n083TPM8j/3+t5dpzeh4GW9kGrpSxZeK5e7M935F9KP7sp9j9+1MWq2+sKL1M9PQbbcv/NvNNHTtNNMo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4AzbyZ5t7maR3kxZeIUxdPZp5nuU0zMQ1v30rns4jjlLyZs+OsaWPTKU9+38VV5zZr75TQTmaW3pucY1NzPs/H9zVrOet+bNOtTT/zZu4/T1N1c+UukXynOZ/PUcpZ98nZLjo082ZuP7d5nufyycylzWznTyeuo5Cz7seucGujmTfzhH5GEP64V13ics3Qz/xprjq3eY8rH/YYJzMnzudUvYZmzs1n8jnrfmzTrW36seHBXOFtnpNXE4cLDObJzDJC0BxrnM/H3weg5qz4sc1QEYFF/HfB3hkAH2gGwAeaAfCBtxnAB/0MgA80A+ADzQD4QDMAPtAMgA+8zQA+8GneQbs9muz+bA+auQM082YecG6zeCqa7vBVnc9G6Hxsj2bgZp7CS0Tn/wW1WeL3/VLbJbAfI490lHPxya/m5dbqi2v6Ih5wbnNMctqr5ny2QvcvD0zHQkdy5mCz7eMU36pp6NYPQ7cWRxg+y72B5eW26ks/0577z23OxJaaqT7H8td8pZI4nJPChwahoPx74VJzUr5lm15uq75opj23n9s8ZwYV+RfHhKOl6tDTfHuNtD5xrKApn9FMjZdbry+aac/t5zYnP+LGf11/YcZvX6exvD8meW/Mtf2MVULGZhdz+7nNY+ZlZmLmUHY+G77oIEt3D6S+fklcN7pVlZopeZtVL7ddX1zT7XnAuc1inWiIFKY7n01fdJC/RzN7kcS6mWiPW6RhUUeccF1NG+U6geptVrzcNfXFNd0azqD9CW2XIuBRoJlfkAyo4D+Gc5uPEj9b/I8qBgZ4mwF84AUA8IFmAHygGQAfaAbAxz/qdN2INihodQAAAABJRU5ErkJggg==" alt="" />
基础写入配置文件
-
-write(fp) 将config对象写入至某个 .init 格式的文件 Write an .ini-format representation of the configuration state.
- -add_section(section) 添加一个新的section
-
-set( section, option, value 对section中的option进行设置,需要调用write将内容写入配置文件
import ConfigParser
import os os.chdir("D:\\Python_config") cf = ConfigParser.ConfigParser() cf.add_section("test")
cf.set("test", "count", 1)
cf.add_section("test1")
cf.set("test1", "name", "aaa") #modify one value and write to file
with open("test2.ini","w+") as f:
cf.write(f)ConfigParser2
- -remove_section(section) 删除某个 section
- -remove_option(section, option) 删除某个 section 下的 option
需要配合文件读写函数来写入文件,示例代码如下
import ConfigParser
import os os.chdir("D:\\Python_config") cf = ConfigParser.ConfigParser() # add section / set option & key
cf.add_section("test")
cf.set("test", "count", 1)
cf.add_section("test1")
cf.set("test1", "name", "aaa") # write to file
with open("test2.ini","w+") as f:
cf.write(f)
ConfigParser2
写入的文件如:aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAATUAAAC5CAIAAADGeD9EAAAeyElEQVR4nO2de3QUVZ7H65/xHzzB/WNm5YyavxTO7pmXzj/tQcQdVufBzKqDSkgEZ88Q10GdRcc1soZRWGARDUSD7MqwigHyptNpCEkgQCCddNIkkMijofPo7iT9CqQfSTqdpBr2j9tVfeuZqu7q6urk9z3fk1O5XbdeXZ/+/e6tqltETbujpt1x3OzUdw7VWoYNl0bqulx1XS5jt/vEZc/JK976Hh/yqZ5R5Ibe2w29t0+Be2+f6r1d3zNa3zN68orvxGXvicte42VvXbfH0OWuveTSW0aOdw7XdAxVm53VZmdVu6OyzV7ZZq8wDSKXtw7M6YrWQRFXmuwJus0h4qp2Z2KuNg+JuWN4Ttd0jCTp450yrLe4tGyiqs1e3W6vMTuOdwggetl78rK3/oqv/koM0fqe0bRToR3TfMYR7fbwIlrV7kgM0ZRQmho+AVHl+eRF1HBppO6Sy9jlPtEdR/TkFR86HeuBUiafOKLGbo8QorxRVAqlCyqKJs+nXErTzqEgn5WmQR5EO4drO4cNlhiixm7Picvek8CnHETrutyGS67aSy4hRDXBpyii6Yqi6vOpWUqJitb+StNApWkA8Rlri3YMIT4Nl1x1TD5xRNMOhqbMjygWQrmJroIN0cQp1R6faclytYkoUdHaX9HaX9k6UGUarG6zIz6PdwzpO4drLSO1TES5UTTtVGjHEhuiNKIoy6UphYZoKqJoxvNZfqGv4mJ/xcUYolVt9up2Rw2FqL5z2HDJxYsoTWnawdCIcT7jDVEJ3bkKdhfNp4Zo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3QBnyC1BXxKF/AJUlvAp3QBnyC1BXxK1/8D3YiAGqv5vH8AAAAASUVORK5CYII=" alt="" />
修改类似写入,注意一定要 read 原文件!
import ConfigParser
import os os.chdir("D:\\Python_config") cf = ConfigParser.ConfigParser() # modify cf, be sure to read!
cf.read("test2.ini")
cf.set("test", "count", 2) # set to modify
cf.remove_option("test1", "name") # write to file
with open("test2.ini","w+") as f:
cf.write(f)
ConfigParser3
上述代码执行后:aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVUAAACyCAIAAAB9WMv3AAAek0lEQVR4nO2dW1AbV5rH+2Xy4hTJPsysXTsJT5tkd2syucyLUrnWeHIl2cSJM9hgOztVUOWJXZmJZ8bEE7JxsrbX4wSbMR5n42ESG3zhKmTZBGPAxkEgkHFsxwQZAbogkBA2SEISAlp4H466dfqiVktqqVvo+9e/KNHq0zf17zvfOS2dQ9R1W+p0Ydd2mWu7zDWYT3WNivK3I1yfvDQs3nQR9KKma7RWZ67Vmeu6LfU91ga9rbF3rMkwrrk8cbrfcbrfob3iPPPd5JnvJs9edZ296mq+NoX8zfVbYGR0QdD1QddKe8V5+opT0+9oujzRdHlCbRhv6B2r19vq9ba6Hmtdj7W221LbbanRmWt0oj/6rtEa5j3Dcq3OEre7rQKu67El5nr9mJB77QJu6B2Xyo19cVhtmEipCRr+Op2lVmepkY7/uKIAl38UAuq6LXQIUPfZUQhAUQCFAOA/4RCgNow39tlRCED8oxAgP/+piQIx+E9jFFBOCCDqmBc9Qf6lyAIEQgCdAqAQQCcCEALiDQGIf4EQkEAKkCn8iwoBgvxLFQIUxH+tYvino4BwK0DdZ0cpADcE0FFAduoUZToEhFOA7yZZrYDGPjvdCkD80yFATBQQ5n85tQKkCgHK5Z83CogNBMk1AQQ6AqK1AiALiIt/4VaAErOA5RsCFBIF+PlPKhGQqCMAvWa1Aup7rNxWQLQQAFEA558OAXhDAA8B3IYAnQIknwUk3goQjAIJhwCFdAfKz3/XoIvfP0xy/e0PzoR9acAh3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uQmCC" alt="" /> [test] 下 count 的值为2; [test1] 下的 name 键值被删除,若需要删除整个 [test1] section,使用 cf.remove_section("test1")
Python 读取写入配置文件 —— ConfigParser的更多相关文章
-
Python 读取写入配置文件 ConfigParser
https://blog.csdn.net/piaodexin/article/details/77371343 https://www.cnblogs.com/feeland/p/4502931.h ...
-
Python读取ini配置文件(接口自动测试必备)
前言 大家应该接触过.ini格式的配置文件.配置文件就是把一些配置相关信息提取出去来进行单独管理,如果以后有变动只需改配置文件,无需修改代码. 特别是后续做自动化的测试,代码和数据分享,进行管理.比如 ...
-
python读取ini配置文件的示例代码(仅供参考)
这篇文章主要介绍了python读取ini配置文件过程示范,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 安装 pip install configp ...
-
python读取yaml配置文件
支持多种语言:python.js.golang.java.c.c++ YAML 语言(发音 /ˈjæməl/ )的设计目标,就是方便人类读写.它实质上是一种通用的数据串行化格式. 它的基本语法规则如下 ...
-
python读取 ini 配置文件
在详解python读取ini文件之前,我们先说明一个ini文件的组成: 一个ini文件是由多个section组成,每个section中以key=vlaue形式存储数据: 然后我们来使用python读取 ...
-
python之模块配置文件ConfigParser(在python3中变化较大)
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之模块ConfigParser(在python3中为configparser) #特别注意:py ...
-
Python读取ini配置文件封装方法
读取配置文件 ----rw_ini.py from configparser import ConfigParser def read_config(config_file_path:str): &q ...
-
Python读取ini配置文件的方式
python configparser模块 ConfigParser模块在python中用来读取配置文件,配置文件的格式跟windows下的ini配置文件相似,可以包含一个或多个节(section ...
-
python读取写入内存方法SringIO,BytesIO
python中不仅仅可以在磁盘中写入文件,还允许直接在内存中直接写入数据:需要借助StringIO和BytesIO来实现: 1.直接操作StringIO from io import StringIO ...
随机推荐
-
问题解决——CVSListBox的使用
=================================版权声明================================= 版权声明:本文为博主原创文章 未经许可不得转载 请通过右 ...
-
C# 二维数组相关知识记录
//初始化一个数组 , ] { { , }, { , }, { , }, { , }, { , } }; //查某个字段的长度 print(name.GetLength()); //获得第一个字段的长 ...
-
vs xamarin android 监听返回键退出程序
public override bool OnKeyDown([GeneratedEnum]Keycode keyCode, KeyEvent e) { if (keyCode == Keycode. ...
-
Java_CookieUtil
package com.willow.util; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequ ...
-
hdu 4105 贪心思想
淋漓尽致的贪心思想 波谷一定是一位数.波峰一位数不够大的时候加入到两位数就一定够大了的. 当在寻找波谷碰到零了就自然当成波谷. 当在寻找波峰时碰到零时,将前面的波谷加到前一个波峰上.让当前的零做波谷, ...
-
web本地存储
Web本地存储 通过本地存储(Local Storage),web 应用程序能够在用户浏览器中对数据进行本地的存储. 在 HTML5 之前,应用程序数据只能存储在 cookie 中,包括每个服务器请求 ...
-
带BOM头文件解析
在java中apache提供了一个工具类BOMStream,在获取文件流时,将获取到的文件流转化成为BOM流: InputStreamReader is = new InputStreamReader ...
-
sqlserver 级联删除、级联更新
增加外键约束时,设置级联更新.级联删除:[ ON DELETE { NO ACTION | CASCADE | SET NULL | SET DEFAULT } ][ ON UPDATE { NO A ...
-
PS不显示图片
最近安装Adobe AIR的时候因为安装不了,删除了相关的配置文件,安装了Adobe AIR之后,用PS打开图片的时候发现不显示图片了,如图: 最后通过万能的百度了解到了是笔记本都采用了双显卡(i3. ...
-
35. Oracle监听器启动出错:本地计算机上的OracleOraDb11g_home1TNSListener服务启动后又停止了解决方案
一.原因分析 你安装oracle的时候是连网的,那么listener.ora文件里的HOST=网络给你分配的IP地址,而在你断网的时候就会出现这样的情况. 三.解决办法 方法一:监听器 通过liste ...