1
0

More than 3 years have passed since last update.

僕のConfigParser(Python)

Last updated at Posted at 2019-12-16

自分用のまとめ
随時更新
自分がわかればいいからところどころ用語が間違ってるかも

!見方

#コマンド
    #引数のオプションの説明

ConfigParserっていつ使うの?

設定ファイル(iniファイル)を扱うとき

モジュール読み込み

import ConfigParser #Python2
import configparser #Python2

頻出操作

こんなiniファイルがあったとする

[I]
name = taro
age = 40
#iniファイルの読み取り
ini = Configparser.SafeConfigParser()
ini.read()
    #引数に読み取るiniファイルのパス

#要素の取得(taroの取得を例に)
#パターン1
name = ini.get['I']['name']
#パターン2
name = ini.get('I','name')

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0