Reputation: 579
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
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
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