# encodemyfile.py # Neal 2009.10.15 # # Read from an input file and write an ascii encoding of the strings # on each line to an output file. def encode(instring): message = [] for ch in instring: message = message + [ord(ch)] # print ord(ch), # debugging stuff # print message # debugging stuff return message def main(): # First open the files name = raw_input("Give me a text file name: ") infile = open(name, 'r') outfile = open("encode.txt",'w') # Encode and output each line of the input file for line in infile: print encode(line) outfile.write(str(encode(line)) + "\n") # put a newline at the end infile.close() outfile.close() print "Now go look at the output file encode.txt" main()