0

I'm trying to open a jpg file with a code in python 2.7 and without some modules.

Here's my attempt:

p='C:/Users/Israe/Desktop/picture.jpg'

with open(p, 'rb') as inf:
    jpgdata = inf.read()

It's showing no errors, but it's doing nothing.

How can I display this image?

erip
  • 16,374
  • 11
  • 66
  • 121
  • 3
    What are you expecting to happen? – Oliver Charlesworth Jun 18 '17 at 13:02
  • It's not doing nothing. You do nothing with the string that's read – OneCricketeer Jun 18 '17 at 13:09
  • You're opening the file and reading its _data_. I edited your question to reflect what I think you're asking. Please feel free to update if this is a mischaracterization. – erip Jun 18 '17 at 13:10
  • I am nominating that this be reopened because the linked dupe uses external libraries, which is explicitly disallowed by OP's question. Frankly, I don't see the problem with the question aside from some (easily resolvable) ambiguity. – erip Jun 18 '17 at 13:12
  • 1
    Since it's impossible to display the image without modules and since the whole concept of python is based on modules, I think we can savely ignore that part of the question and leave it closed. – ImportanceOfBeingErnest Jun 18 '17 at 13:16
  • @ImportanceOfBeingErnest Surely sys calls could be listed, albeit not very portable. – erip Jun 18 '17 at 13:19
  • So you are honestly thinking that OP is looking for a solution where he needs to reimplement all the stuff that modules like pillow or sys would provide? I would say there is no indication for that in the question and that this half sentence is rather due to some lack of knowledge than due to the profound aim of customized image loading and displaying. – ImportanceOfBeingErnest Jun 18 '17 at 13:24
  • 2
    @erip Feel free to post an answer not using external libraries on the duplicate. There's no reason to open this post when that one exists. We should consolidate posts – OneCricketeer Jun 18 '17 at 13:25

0 Answers0