質問編集履歴
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -146,6 +146,8 @@
|
|
146
146
|
|
147
147
|
実行したことは画像が保存されるごとに画像の名前を変えて保存したいです。
|
148
148
|
|
149
|
+
そのためにdatetime.now()の箇所を変えないといけないのですがどう変えていいのかわからず質問させていただきました。
|
150
|
+
|
149
151
|
```
|
150
152
|
|
151
153
|
import requests
|
1
編集
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ValueError: I/O operation on closed file というエラーが出てしまう。
|
test
CHANGED
@@ -4,27 +4,135 @@
|
|
4
4
|
|
5
5
|
```
|
6
6
|
|
7
|
+
9\x11@\x1d\xd6f\x1bO\\x0c\x1c\xf5\x185\xcek\x9e6\xbe\xbe\x9f\xca\x02G\xc6\xe2\x1d$}\xee\xd9%\x8b\x00\xdc\x8e2O\xd7\x8a\xa0\x9a6\xbfw\x033\'\xca\xd9\x92GT?+`\x809\xfa\x8c\x91\xfe5\xa3\xa5\xf8v\xd2\x00\xbet{\xb6\x1d\xcd+7\uS\x8fa\xeb\xff\x00\xd
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
このような文字がいっぱい続いてました。
|
12
|
+
|
13
|
+
|
14
|
+
|
7
15
|
---------------------------------------------------------------------------
|
8
16
|
|
9
|
-
|
10
|
-
|
11
|
-
<ipython-input-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
4
|
16
|
-
|
17
|
-
--->
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
17
|
+
ValueError Traceback (most recent call last)
|
18
|
+
|
19
|
+
<ipython-input-1-4b147de06743> in <module>
|
20
|
+
|
21
|
+
53 }
|
22
|
+
|
23
|
+
54 response = requests.post(face_api_url, headers=headers,
|
24
|
+
|
25
|
+
---> 55 params=params, data=image_data)#FaceAPIで解析
|
26
|
+
|
27
|
+
56
|
28
|
+
|
29
|
+
57 response.raise_for_status()
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
E:\Anaconda\envs\env\lib\site-packages\requests\api.py in post(url, data, json, **kwargs)
|
34
|
+
|
35
|
+
117 """
|
36
|
+
|
37
|
+
118
|
38
|
+
|
39
|
+
--> 119 return request('post', url, data=data, json=json, **kwargs)
|
40
|
+
|
41
|
+
120
|
42
|
+
|
43
|
+
121
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
E:\Anaconda\envs\env\lib\site-packages\requests\api.py in request(method, url, **kwargs)
|
48
|
+
|
49
|
+
59 # cases, and look like a memory leak in others.
|
50
|
+
|
51
|
+
60 with sessions.Session() as session:
|
52
|
+
|
53
|
+
---> 61 return session.request(method=method, url=url, **kwargs)
|
54
|
+
|
55
|
+
62
|
56
|
+
|
57
|
+
63
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
E:\Anaconda\envs\env\lib\site-packages\requests\sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
|
62
|
+
|
63
|
+
514 hooks=hooks,
|
64
|
+
|
65
|
+
515 )
|
66
|
+
|
67
|
+
--> 516 prep = self.prepare_request(req)
|
68
|
+
|
69
|
+
517
|
70
|
+
|
71
|
+
518 proxies = proxies or {}
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
E:\Anaconda\envs\env\lib\site-packages\requests\sessions.py in prepare_request(self, request)
|
76
|
+
|
77
|
+
457 auth=merge_setting(auth, self.auth),
|
78
|
+
|
79
|
+
458 cookies=merged_cookies,
|
80
|
+
|
81
|
+
--> 459 hooks=merge_hooks(request.hooks, self.hooks),
|
82
|
+
|
83
|
+
460 )
|
84
|
+
|
85
|
+
461 return p
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
E:\Anaconda\envs\env\lib\site-packages\requests\models.py in prepare(self, method, url, headers, files, data, params, auth, cookies, hooks, json)
|
90
|
+
|
91
|
+
315 self.prepare_headers(headers)
|
92
|
+
|
93
|
+
316 self.prepare_cookies(cookies)
|
94
|
+
|
95
|
+
--> 317 self.prepare_body(data, files, json)
|
96
|
+
|
97
|
+
318 self.prepare_auth(auth, url)
|
98
|
+
|
99
|
+
319
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
E:\Anaconda\envs\env\lib\site-packages\requests\models.py in prepare_body(self, data, files, json)
|
104
|
+
|
105
|
+
476 if is_stream:
|
106
|
+
|
107
|
+
477 try:
|
108
|
+
|
109
|
+
--> 478 length = super_len(data)
|
110
|
+
|
111
|
+
479 except (TypeError, AttributeError, UnsupportedOperation):
|
112
|
+
|
113
|
+
480 length = None
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
E:\Anaconda\envs\env\lib\site-packages\requests\utils.py in super_len(o)
|
118
|
+
|
119
|
+
118 elif hasattr(o, 'fileno'):
|
120
|
+
|
121
|
+
119 try:
|
122
|
+
|
123
|
+
--> 120 fileno = o.fileno()
|
124
|
+
|
125
|
+
121 except io.UnsupportedOperation:
|
126
|
+
|
127
|
+
122 pass
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
ValueError: I/O operation on closed file
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
28
136
|
|
29
137
|
```
|
30
138
|
|
@@ -84,11 +192,11 @@
|
|
84
192
|
|
85
193
|
##Faceの設定
|
86
194
|
|
87
|
-
subscription_key = '
|
195
|
+
subscription_key = '####################'#ここに取得したキー1を入力
|
88
196
|
|
89
197
|
assert subscription_key
|
90
198
|
|
91
|
-
face_api_url = 'https://
|
199
|
+
face_api_url = 'https://#######.cognitiveservices.azure.com/face/v1.0/detect'#ここに取得したエンドポイントのURLを入力
|
92
200
|
|
93
201
|
|
94
202
|
|
@@ -116,7 +224,7 @@
|
|
116
224
|
|
117
225
|
for face in faces:
|
118
226
|
|
119
|
-
now =
|
227
|
+
now = 1#撮影時間
|
120
228
|
|
121
229
|
filename = "face{}.jpg".format(now)#保存するfilename
|
122
230
|
|