Skip to content

程序设计 #19

@eziceice

Description

@eziceice

配置文件

  • 可以将所有固定的常量放置到一个配置文件中, 这样用户就可以比较容易的直接更改程序中常量的值.
from configparser import *

CONFIGFILE = 'config.txt'
config = ConfigParser()
config.read(CONFIGFILE)

print(config.get('numbers', 'pi'))
print(config.get('messages', 'greeting')) #第一个参数是所要获取的区块, 第二个参数则是config的名字

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions