pylhb 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pylhb/myconfig.py ADDED
@@ -0,0 +1,37 @@
1
+ """
2
+ 模块:myconfig
3
+ 作者:李生
4
+ """
5
+ import configparser
6
+ import os
7
+
8
+ class MyConfig:
9
+ def __init__(self, configFile="config.ini"):
10
+ self.configFile = configFile
11
+ if not os.path.exists(self.configFile):
12
+ with open(self.configFile, 'w', encoding='gb2312') as f:
13
+ f.write("[main]\n")
14
+ self.cf = configparser.ConfigParser()
15
+ self.cf.read(self.configFile, encoding='gb2312')
16
+
17
+ # 获取节点值
18
+ def get(self, section, option,defaultValue=""):
19
+ if self.cf.has_section(section) and self.cf.has_option(section, option):
20
+ return self.cf.get(section, option)
21
+ return defaultValue
22
+
23
+ # 设置节点值
24
+ def set(self, section, option, value):
25
+ if self.cf.has_section(section) is False:
26
+ self.cf.add_section(section)
27
+ self.cf.set(section, option, value)
28
+ with open(self.configFile, 'w', encoding='gb2312') as f:
29
+ self.cf.write(f)
30
+
31
+ # 删除节点
32
+ def remove(self, section, option):
33
+ self.cf.remove_option(section, option)
34
+ with open(self.configFile, 'w', encoding='gb2312') as f:
35
+ self.cf.write(f)
36
+
37
+
pylhb/myodbc.py CHANGED
@@ -1,5 +1,5 @@
1
1
  '''
2
- 模块:pyodbc封装
2
+ 模块:myodbc
3
3
  作者:李生
4
4
  注意:
5
5
  ODBC Driver 17 for SQL Server下载:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pylhb
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Mr.Lee's Helpers
5
5
  License: Non-Commercial Use License
6
6
 
@@ -109,3 +109,16 @@ if __name__ == "__main__":
109
109
  # 关闭
110
110
  mssql.close()
111
111
  ```
112
+
113
+ ## 🌺myconfig
114
+
115
+ 通过configparser读取配置文件。
116
+
117
+ 使用示例:
118
+
119
+ ```
120
+ if __name__ == "__main__":
121
+ config = MyConfig("config.ini")
122
+ config.set("main", "host", "127.0.0.1")
123
+ print(config.get("main", "host"))
124
+ ```
@@ -0,0 +1,7 @@
1
+ pylhb/__init__.py,sha256=w-OXDD2tii5g0E0kWQYl-LP0C1LSezXFkUCe5cgO-nY,51
2
+ pylhb/myconfig.py,sha256=skaiIe2jfnWj4X3bfbBqBpygkcrDZ2rMKxX_CBKekms,1223
3
+ pylhb/myodbc.py,sha256=E5yiSSaN8_CtW40IeY_jJcgPlW3KBrZVN5t7UCh0RSQ,7721
4
+ pylhb-0.2.1.dist-info/WHEEL,sha256=eycQt0QpYmJMLKpE3X9iDk8R04v2ZF0x82ogq-zP6bQ,79
5
+ pylhb-0.2.1.dist-info/entry_points.txt,sha256=JgRWNHrbkaBFjPwbIi60UzpImMHwTtOchFnclGWMqeY,38
6
+ pylhb-0.2.1.dist-info/METADATA,sha256=ehnZVkxrvE10_bTqxN9GVAA6kR0OgsRFJgDQJosHJWU,4548
7
+ pylhb-0.2.1.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- pylhb/__init__.py,sha256=w-OXDD2tii5g0E0kWQYl-LP0C1LSezXFkUCe5cgO-nY,51
2
- pylhb/myodbc.py,sha256=6cmnJuOQ34UOEeEL942zhGngs53pk27-VW6Vo6t2PD0,7727
3
- pylhb-0.2.0.dist-info/WHEEL,sha256=eycQt0QpYmJMLKpE3X9iDk8R04v2ZF0x82ogq-zP6bQ,79
4
- pylhb-0.2.0.dist-info/entry_points.txt,sha256=JgRWNHrbkaBFjPwbIi60UzpImMHwTtOchFnclGWMqeY,38
5
- pylhb-0.2.0.dist-info/METADATA,sha256=SJ2HtZjq-LHppo8lyf46XwcTh59KWFHVEnbTSNZHtoU,4319
6
- pylhb-0.2.0.dist-info/RECORD,,
File without changes