Dictionary型をそのまま設定ファイルとして出力したい場合がある。
そんなときは下記のようなスクリプトを使うと楽。
config = {
"A":"a",
"B":"b",
"C":"c"
}
config = '¥n'.join(map('='.join, config.iteritems())
# config= "A=a¥nB=b¥nC=c"
このconfigが望んでいた文字列になっているのでこれを書き出す。
Go to list of users who liked
Share on X(Twitter)
Share on Facebook
More than 5 years have passed since last update.
Dictionary型をそのまま設定ファイルとして出力したい場合がある。
そんなときは下記のようなスクリプトを使うと楽。
config = {
"A":"a",
"B":"b",
"C":"c"
}
config = '¥n'.join(map('='.join, config.iteritems())
# config= "A=a¥nB=b¥nC=c"
このconfigが望んでいた文字列になっているのでこれを書き出す。
Register as a new user and use Qiita more conveniently
Go to list of users who liked