Opening files

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2009
Posts: 57
Reputation: Dan08 is an unknown quantity at this point 
Solved Threads: 2
Dan08 Dan08 is offline Offline
Junior Poster in Training

Opening files

 
0
  #1
Aug 21st, 2009
Is it possible to open windows files with python?
Like notepad, and stuff..

Thanks Dan08.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 231
Reputation: sravan953 has a little shameless behaviour in the past 
Solved Threads: 28
sravan953's Avatar
sravan953 sravan953 is offline Offline
Posting Whiz in Training

Re: Opening files

 
0
  #2
Aug 21st, 2009
Yes, yes you can!

If you want to open a .txt file named: "log.txt" which is in the same directory as where you are working from:
  1. log=open("log.txt",'r')
  2. """
  3. Here, you can replace 'log' with any name you want. And 'r' specifies that you want to read from the file, whereas 'w' specifies that you want to write to a document.
  4. """
  5. log_read=log.read()
  6. # read() method returns a string variable
  7. log_readlines=log.readlines()
  8. # readlines() returns a variable of list data type
Last edited by sravan953; Aug 21st, 2009 at 10:56 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 163
Reputation: snippsat is an unknown quantity at this point 
Solved Threads: 49
snippsat snippsat is offline Offline
Junior Poster

Re: Opening files

 
1
  #3
Aug 21st, 2009
If you want to open notepad.
You can use the os module.
  1. import os
  2. os.system('start notepad.exe')
  3.  
  4. #Open a webpage
  5. os.system('start iexplore.exe http://www.google.com')
Last edited by snippsat; Aug 21st, 2009 at 11:39 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 57
Reputation: Dan08 is an unknown quantity at this point 
Solved Threads: 2
Dan08 Dan08 is offline Offline
Junior Poster in Training

Re: Opening files

 
0
  #4
Aug 22nd, 2009
Originally Posted by snippsat View Post
If you want to open notepad.
You can use the os module.
  1. import os
  2. os.system('start notepad.exe')
Thats exactly what i wanted to do, thanks snippsat.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC