Hello! I want to convert compiled files to text files. I believe compiled files are binary files.
I am able to convert a given string to binary and back to text. But when it comes to a file it is proving to be impossible. <code> def p(a): s=open(a,'rb') for x in s: d=map(lambda y:chr(int(y,2)),x) print d s.close() >>> p("C:/pp.txt") Traceback (most recent call last): File "<pyshell#53>", line 1, in <module> p("C:/pp.txt") File "<pyshell#52>", line 5, in p d=map(lambda y:chr(int(y,2)),x) File "<pyshell#52>", line 5, in <lambda> d=map(lambda y:chr(int(y,2)),x) ValueError: invalid literal for int() with base 2: 'f' </code> Please some one point where the problem is.
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor