質問するログイン新規登録

回答編集履歴

3

書き込み時のエンコーディングを指定

2020/08/10 00:56

投稿

Daregada
Daregada

スコア11992

answer CHANGED
@@ -12,6 +12,6 @@
12
12
 
13
13
  config['DEFAULT']['line1'] = str(1) # 値は文字列として設定
14
14
 
15
- with open("settings.ini", "w") as configfile:
15
+ with open("settings.ini", "w", encoding="utf-8") as configfile:
16
- config.write(configfile, True, encoding="utf-8")
16
+ config.write(configfile, True)
17
17
  ```

2

補足を追加

2020/08/10 00:56

投稿

Daregada
Daregada

スコア11992

answer CHANGED
@@ -13,5 +13,5 @@
13
13
  config['DEFAULT']['line1'] = str(1) # 値は文字列として設定
14
14
 
15
15
  with open("settings.ini", "w") as configfile:
16
- config.write(configfile, True)
16
+ config.write(configfile, True, encoding="utf-8")
17
17
  ```

1

Pythonのコメントは#だよね

2020/08/10 00:55

投稿

Daregada
Daregada

スコア11992

answer CHANGED
@@ -10,7 +10,7 @@
10
10
  config = configparser.ConfigParser()
11
11
  config.read("settings.ini", "utf-8")
12
12
 
13
- config['DEFAULT']['line1'] = str(1) // 値は文字列として設定
13
+ config['DEFAULT']['line1'] = str(1) # 値は文字列として設定
14
14
 
15
15
  with open("settings.ini", "w") as configfile:
16
16
  config.write(configfile, True)