![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2009
Posts: 1
Rep Power: 0
![]() |
How to save results from script to a txt file
Here is my code atm
room_num = raw_input("Enter your room number: ") text_file = open("c:/roombookings.txt", "r") whole_thing = text_file.readline() if room_num in whole_thing: print "Room number found here is the information:" else : print "Room number not found." single_line = whole_thing.split('\n') for single_line in text_file.readlines(): if room_num in single_line: print single_line fileObj = open("courseinfo.dat","w") fileObj.write(??????????) fileObj.close() text_file.close() The user types in a roomnumber and the script displays the information regarding the roomnumber only. What i need to do is have the script save the same data to a seperate file. I can get the script to create the file but not the results from the search. I am 85% sure that where i have the ????????? is where the answer lies... however i am not smart enough to know exactly what i am doing wrong ![]() What should i be doing that i have forgotten? |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need a Perl script to parse a file out and loop it | richsark | Perl | 6 | Feb 20th, 2009 7:36 AM |
| printing a txt file issue | badbasser98 | C++ | 2 | Jun 22nd, 2007 12:31 PM |
| How to save all search engine results urls in a text file | abojan | ASP | 0 | Dec 27th, 2006 9:33 AM |
| Windows batch file script | chronosoft | Other Scripting Languages | 6 | Oct 10th, 2006 10:43 AM |
| script to obtain jpgs and compress them and save them to an output file | Jimineep | Bash / Shell Scripting | 2 | May 18th, 2005 10:16 AM |