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

質問編集履歴

1

codeボタンを押してcodeを貼り付けました。エラーメッセージも掲載しました。

2021/12/25 23:34

投稿

Risekorise
Risekorise

スコア1

title CHANGED
File without changes
body CHANGED
@@ -5,20 +5,28 @@
5
5
 
6
6
  ※先にダウンロードしてあるサンプルファイルchap2-11.pyを実行しても同じ現象が生じます。
7
7
 
8
+ ```言語 Python 【バージョン】Python 3.6.1
8
- コード
9
+ コード
10
+
9
11
  import requests
10
12
 
11
- # 画像ファイルを取得する
13
+ #画像ファイルを取得する
12
14
  image_url = "https://www.ymori.com/books/python2nen/sample1.png"
13
15
  imgdata = requests.get(image_url)
14
16
 
15
- # URLから最後のファイル名を取り出す
17
+ #URLから最後のファイル名を取り出す
16
18
  filename = image_url.split("/")[-1]
17
19
 
18
- # 画像データを、ファイルに書き出す
20
+ #画像データを、ファイルに取り出す
19
21
  with open(filename, mode="wb") as f:
20
- f.write(imgdata.content)
22
+ f.write(imgdata.content)
21
23
 
22
24
 
23
- 【バージョン】
25
+ ```
26
+
27
+ 【エラーメッセージ】このようなエラーが表示され画像も表示されません
28
+ Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
29
+ Type "copyright", "credits" or "license()" for more information.
24
- Python 3.6.1
30
+ >>>
31
+ ==== RESTART: C:\Users\User\Documents\python\phython2年生\chap2 chap2-11.py ====
32
+ >>>