Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change my current working directory in Python to my external hard drive.

Tags:

python-2.7

I am working on a project which requires me to process large amounts of uncompressed video data so I need to store all the data on my external hard drive. So far I have obtained the cwd with:

import os
os.getcwd()

And I know how to change the directory with the following command:

path='E:\College\Project\3dlife-gc-2013-dataset-hhi\3dlife-gc-2013-dataset-hhi'
os.chdir(path)

This command does not allow me to change the cwd as I desire. I suspect that my path is not formatted correctly. Thanks for reading :)

like image 426
P Rowsome Avatar asked Oct 04 '22 17:10

P Rowsome


1 Answers

You are correct.

>>> 'E:\College\Project\3dlife-gc-2013-dataset-hhi\3dlife-gc-2013-dataset-hhi'
'E:\\College\\Project\x03dlife-gc-2013-dataset-hhi\x03dlife-gc-2013-dataset-hhi'

Double the backslashes, use forward slashes, or use a raw string.

like image 118
Ignacio Vazquez-Abrams Avatar answered Oct 07 '22 20:10

Ignacio Vazquez-Abrams