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

回答編集履歴

1

追記

2021/04/10 06:57

投稿

quickquip
quickquip

スコア11314

answer CHANGED
@@ -1,2 +1,15 @@
1
1
  joblib.dump(〜) が作るファイルは[テキストファイルじゃありません](https://joblib.readthedocs.io/en/latest/persistence.html#persistence)。
2
- テキストファイルじゃないものにtxtという拡張子を付けているので、PyCharmはテキストファイルとして読みこもうとしますが、PyCharmが扱えるすべてのエンコーディングで試してみても当然うまく読み出せん。それでエラーになります。
2
+ テキストファイルじゃないものにtxtという拡張子を付けているので、PyCharmはテキストファイルとして読みこもうとしますが、PyCharmが扱えるすべてのエンコーディングで試してみても当然うまく読み出せん。それでエラーになります。
3
+
4
+ ----
5
+
6
+ リストを単純に文字列に変換すると同じ形になるので、基本的なファイルへの書き出しで十分そうですね。
7
+
8
+ [https://docs.python.org/ja/3/tutorial/inputoutput.html#reading-and-writing-files](https://docs.python.org/ja/3/tutorial/inputoutput.html#reading-and-writing-files)
9
+ [https://docs.python.org/ja/3/library/functions.html#print](https://docs.python.org/ja/3/library/functions.html#print)
10
+
11
+ ```python
12
+ with open("temp.txt", "w") as w:
13
+ print(temp_list, file=w)
14
+ ```
15
+ でいいと思います。