| | |
Opening files
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
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:
If you want to open a .txt file named: "log.txt" which is in the same directory as where you are working from:
python Syntax (Toggle Plain Text)
log=open("log.txt",'r') """ 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. """ log_read=log.read() # read() method returns a string variable log_readlines=log.readlines() # readlines() returns a variable of list data type
Last edited by sravan953; Aug 21st, 2009 at 10:56 pm.
•
•
Join Date: Aug 2008
Posts: 163
Reputation:
Solved Threads: 49
If you want to open notepad.
You can use the os module.
You can use the os module.
python Syntax (Toggle Plain Text)
import os os.system('start notepad.exe') #Open a webpage os.system('start iexplore.exe http://www.google.com')
Last edited by snippsat; Aug 21st, 2009 at 11:39 pm.
•
•
Join Date: Jul 2009
Posts: 57
Reputation:
Solved Threads: 2
•
•
•
•
If you want to open notepad.
You can use the os module.
python Syntax (Toggle Plain Text)
import os os.system('start notepad.exe')
![]() |
Similar Threads
- XP explorer slow opening files (Windows NT / 2000 / XP)
- microsoft world files are not opening (Viruses, Spyware and other Nasties)
- opening two files simultaneously (Visual Basic 4 / 5 / 6)
- Trouble opening certain files... (Windows 95 / 98 / Me)
Other Threads in the Python Forum
- Previous Thread: tkFileDialog
- Next Thread: What is EOF and what it it's significane in python?
| Thread Tools | Search this Thread |
accessdenied advanced application argv beginner change color command convert csv cursor def dictionary digital dynamic dynamically edit editing enter event examples excel file float format frange function google gui homework i/o import input jaunty java keyboard lapse line linux list lists loop microphone mouse movingimageswithpygame newb number numbers numeric obexftp output parameters parsing path port prime programming projects py2exe pygame pygtk pyopengl python random recursion remote return reverse scrolledtext session simple skinning smtp sprite stderr string strings subprocess syntax table tennis terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode unit urllib urllib2 variable voip web-scrape windows wxpython





