美文网首页
python解析命令行参数读取和配置文件的读取

python解析命令行参数读取和配置文件的读取

作者: 好大一只鹏 | 来源:发表于2019-02-21 17:18 被阅读0次

1.当我们输入的命令带有参数的时候可以使用sys模块的解析参数

def analyze_command_params():
    """
    解析命令行参数
    """
    command_argv = sys.argv

2.读取配置文件
例如配置文件如下:

[baseconf]
host=127.0.0.1
port=3306
user=root
password=root
db_name=gloryroad
[test]
ip=127.0.0.1
int=1
float=1.5
bool=True

还在发布中

相关文章

网友评论

      本文标题:python解析命令行参数读取和配置文件的读取

      本文链接:https://www.haomeiwen.com/subject/zbhdyqtx.html