1. ConfigParser format.conf [DEFAULT] conn_str = %(dbn)s://%(user)s:%(pw)s@%(host)s:%(port)s/%(db)s dbn = mysql user = root host = localhost port = 3306 [db1] user = aaa pw = ppp db = example [db2] host = 172.16.88.1 pw = www db = example readformati…
__getattr____getattr__在当前主流的Python版本中都可用,重载__getattr__方法对类及其实例未定义的属性有效.也就属性是说,如果访问的属性存在,就不会调用__getattr__方法.这个属性的存在,包括类属性和实例属性. Python官方文档的定义 Called when an attribute lookup has not found the attribute in the usual places (i.e. it is not an instance a…