回答編集履歴
2
元のソースコードにスタイルを合わせるよう修正。
answer
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
```Python
|
3
3
|
encoding = "utf-8"
|
4
4
|
# encoding = "cp932" # utf-8がだめならこっちを試してみてください。
|
5
|
-
|
5
|
+
f = open("filename.xml", encoding=encoding)
|
6
|
-
|
6
|
+
root = ElementTree.parse(f)
|
7
7
|
```
|
8
8
|
文字コードのトラブル
|
9
9
|
* [https://teratail.com/questions/137252](https://teratail.com/questions/137252)
|
1
追記
answer
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
ファイルを開く際に文字コードを教えてやるとうまくいくかもしれません。
|
2
2
|
```Python
|
3
|
+
encoding = "utf-8"
|
4
|
+
# encoding = "cp932" # utf-8がだめならこっちを試してみてください。
|
3
|
-
with open("filename.xml", encoding=
|
5
|
+
with open("filename.xml", encoding=encoding) as f:
|
4
6
|
root = ElementTree.parse(f)
|
5
7
|
```
|
6
8
|
文字コードのトラブル
|