回答編集履歴
1
追記
answer
CHANGED
@@ -1,2 +1,13 @@
|
|
1
1
|
原因は`FileNotFoundError: [Errno 2] No such file or directory: 'hasira.png'`です。
|
2
|
-
カレントディレクトリに画像ファイルを配置してください。一般的には`kime4.py`と同じ場所でよいです。
|
2
|
+
カレントディレクトリに画像ファイルを配置してください。一般的には`kime4.py`と同じ場所でよいです。
|
3
|
+
|
4
|
+
以下のようなコードでファイルの存在確認ができます。
|
5
|
+
```Python
|
6
|
+
import os
|
7
|
+
|
8
|
+
img_path = 'hasira.png'
|
9
|
+
print( img_path, os.path.exists(img_path))
|
10
|
+
img_path = os.path.join( os.getcwd(), 'hasira.png') # getcwdはカレントディレクトリパスを返す
|
11
|
+
print(img_path, os.path.exists( img_path))
|
12
|
+
:
|
13
|
+
```
|