pickling to an output file.

Smiley 4321 ssmile03 at gmail.com
Tue Feb 28 13:23:36 CET 2012


I have created a bytestream (readfile.pkl) from pickle.dump() already in
different folder (say /tmp) succesfully. Now I wish to open the file, read
it and finally write the output to a file to "output.txt".

To read the file bytestream file (readfile.pkl) I did perform as --

---
import pickle

def print_report():
    with open('/tmp/readfile.pkl', 'rb') as f:
        my_shared = pickle.load(f)
            print my_shared
    print "================================================================"

--

My above code should perform all 3 of below -

(a) Open the pickle file as above
(b) read the pickled object
(c) write the output to a file say "output.txt"

Can I have know if my above code is reading properly and how to write to an
output file 'output.txt'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120228/c9ceedad/attachment.html>


More information about the Python-list mailing list