Change the current working directory in Python to an external hard drive.

I am working on a project that requires me to process a large amount of uncompressed video data, so I need to save all the data on my external hard drive. So far, I got 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 modify cwd as I wish. I suspect my path is not formatted correctly. Thank you for reading:)

+4
source share
1 answer

You're right.

 >>> '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 backslash, use a slash or use a raw string.

+3
source

Source: https://habr.com/ru/post/1488082/


All Articles