open a file in python
jayshree06comp at gmail.com
Wed Jul 29 08:58:36 CEST 2009
On Jul 27, 2:55 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> jayshree wrote:
> > On Jul 27, 1:09 pm, Kushal Kumaran <kushal.kumaran+pyt... at gmail.com>
> > wrote:
> >> On Mon, Jul 27, 2009 at 12:58 PM, jayshree<jayshree06c... at gmail.com>
> >> wrote:
> >> > pk = open('/home/jayshree/my_key.public.pem' , 'rb').read()
> >> > Please tell me how to open a file placed in any directory or in same
> >> > directory.
> >> > After opening this file i want to use the contain (public key ) for
> >> > encryption
> >> Does the code you've put into your message not read that file? If you
> >> get an exception, copy-paste in the traceback message you get into
> >> your mail.
> >> --
> >> kushal
> > try:
> > pk = open('/home/jayshree/my_key.public.pem' , 'rb').read()
> > except IOError:
> > print "Error: can\'t find file or read data"
> > else:
> > print "reading from file successfully"
> >>Still no error it gives .what to do?
> Erm - so it doesn't give an error - which means you have successfully opened
> a file, and read it's contents.
> So what exactly is your problem?
> Diez- Hide quoted text -
> - Show quoted text -
> The Exact Problem is how to use the key containing by .pem file for 'encryption' .
>can i print the contents of the .pem file
More information about the Python-list