回答編集履歴

2

元のソースコードにスタイルを合わせるよう修正。

2018/07/23 07:57

投稿

tachikoma
tachikoma

スコア3601

test CHANGED
@@ -6,9 +6,9 @@
6
6
 
7
7
  # encoding = "cp932" # utf-8がだめならこっちを試してみてください。
8
8
 
9
- with open("filename.xml", encoding=encoding) as f:
9
+ f = open("filename.xml", encoding=encoding)
10
10
 
11
- root = ElementTree.parse(f)
11
+ root = ElementTree.parse(f)
12
12
 
13
13
  ```
14
14
 

1

追記

2018/07/23 07:57

投稿

tachikoma
tachikoma

スコア3601

test CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  ```Python
4
4
 
5
+ encoding = "utf-8"
6
+
7
+ # encoding = "cp932" # utf-8がだめならこっちを試してみてください。
8
+
5
- with open("filename.xml", encoding="utf-8") as f:
9
+ with open("filename.xml", encoding=encoding) as f:
6
10
 
7
11
  root = ElementTree.parse(f)
8
12