zoukankan      html  css  js  c++  java
  • Python之读取文件配置

    借鉴:https://my.oschina.net/u/3041656/blog/793467

    配置文件用于存储程序中的配置数据。配置文件会被分组(比如“config”和“cmd”),没个分组在其中有对应的各个变量值。如下:

    #定义config分组

    [config]

    platformName = Android

    appPackage = com.romwe

    appActivity = com.romwe.SplashActivity

    #定义cmd分组

    [cmd]

    viewPhone = adb devices

    startServer = adb start-server

    stopServer = adb kill-server

    #定义log分组

    [log]

    log_error = true

    基本的读取操作:

    read(filename)          直接读取文件文件内容

    section()                   得到所有的section,并以列表的形式返回

    options(section)        得到该section的所有option

    items(section)           得到该section的所有键值对

    get(section,option)    得到section中的option的值,返回为string类型

    getint(section,option)  得到section中option的值,返回为int类型,还有相应的getboolean()和getfloat函数

  • 相关阅读:
    解决asp.net mvc的跨域请求问题
    centos安装nodejs
    webapi中配置返回的时间数据格式
    centos安装django
    在Linux CentOS 6.6上安装Python 2.7.9
    nginx日志切割脚本
    apache单ip配置多端口多站点
    centos开启rewrite功能
    Fast Matrix Operations
    1400
  • 原文地址:https://www.cnblogs.com/zzzidea/p/7200648.html
Copyright © 2011-2022 走看看