回答編集履歴

1

追記

2020/07/07 08:13

投稿

can110
can110

スコア38256

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