A
A
Alexey Poloz2017-09-17 18:38:29
Python
Alexey Poloz, 2017-09-17 18:38:29

Python How to open file not from computer in binary mode?

To send photos from a computer to the server, I use this: But if you insert a link from the site, for example
open('bla.jpg', 'rb')

i.stack.imgur.com/bq6O5.png
, does not work:

Traceback (most recent call last):
File "", line 1, in
FileNotFoundError: [Errno 2] No such file or directory: ' i.stack.imgur.com/bq6O5.png '

How can I open this image without downloading it to my computer?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tyomitch, 2017-10-03
@tyomitch

import urllib2
response = urllib2.urlopen('http://i.stack.imgur.com/bq6O5.png')
data = response.read()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question