Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Path in Python

Status
Not open for further replies.

bradm279

Technical User
Jun 14, 2007
1
US
I'm trying to read a txt file into python but it is not opening the file. When I looked at the path browser I realized it wasn't reading where my file was but there were no options on how to change it. If anyone could help it would be appreciated.
Brad
 
Code:
import sys
sys.path.append("/new/path") 
file("filename", "r")

OR

Code:
import os
os.chdir("/new/path")
file("filename", "r")

OR

Code:
file("/new/path/filename", "r")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top