thanks for your answer.

I known how to do it.
read() return a string. so
1) bytes = read(1) #read the file by bit.
2) chrString  = ord(bytes) #convert the string to ASCII.
3) print numberToBinary(chrString) #convert the ASCII to Binary using
my function.
4) Loop

I do it because I want to encrypt a string into a picture using RSA
algorithm.
so I first convert the string to binary,and then saving the binary into
picture

finally, print the picture by binary!

It is my coursework and studying PYTHON passingly : )

Marc 'BlackJack' Rintsch wrote:
> In <[EMAIL PROTECTED]>, Lucas wrote:
>
> > I need print a file in binary mode .
> >
> > f = f.open('python.jpg','rb')
> > bytes = f.read()
> > f.close()
> >
> > print(bytes)
> >
> > I can't get any binary code.
>
> What do you mean by "binary code"?  If you use ``print repr(bytes)``
> everything outside ASCII will be printed as escape sequence.
>
> But why do you want to "print" JPEG images anyway?
> 
> Ciao,
>       Marc 'BlackJack' Rintsch

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to