1.11M Members

File Paths in Python

 
0
 

I am relatively new to Python and just have a couple quick questions about using file paths in Python code.

1) As I was recently playing around with the command line, I could not get a file path to work correctly unless I used forward slashes in the path...for example:

reader = csv.reader(open('C:/Folder/Folder/file.txt', 'wb'))

However, I wrote a program previously that used the backslash and everything worked just fine. Is there a time to use the backslash and time to use the forward slash or does it not matter?

2) I was also trying to use the path to a shared file on the network drive recently and Python did not seem to like the path

path = "\\VPC\Scala Test\Movies 10-12-09"

for example. Can shared folders be referenced in a Python program or do the files have to be on the hard drive of the computer the program is written on?

Thanks

 
1
 

backslash is native to windows as forwardslash to linux/unix/bsd file path. if you want to write an app. for network , then your good choice shout be forwardslash.

Question Answered as of 3 Years Ago by richieking
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: