real_actor
real_actor

Reputation: 579

Open python shell in the current directory

I want to open a python shell in the current directory like cmd. My system is windows 10. How can I achieve that?

I would like to perform something like that:

Suppose that I open a directory on D disk, let's say the path is D:\PythonProjects. I open cmd in current directory, in cmd I type python to get a python shell, but the work directory of python didn't change.

Upvotes: 1

Views: 10445

Answers (2)

Aadish Goel
Aadish Goel

Reputation: 481

You can just simply open shell and than

import os
os.chdir(" ")

In between quotes you can specify path were you want to open that

You can also see current path by

os.getcwd()

Upvotes: 4

aliasm2k
aliasm2k

Reputation: 901

Did you try something like this in command line?

C:> D:
D:> cd PythonProjects
D:\PythonProjects> python
[Something about Python interpreter]
>>>

Upvotes: 4

Related Questions