[Python] Check the current directory, move the directory

[Python] Check the current directory (folder), move the directory

Check the current directory

You can get the current directory with ** os.getcwd () **.

Example

import os

path = os.getcwd() #Get current directory
print(path)

# C:\Users\hiro22

Move directory

You can move to the specified directory with ** os.chdir (r'path of the specified directory') **.

Example

import os

os.chdir(r"C:\Users\hiro22\Desktop\test") #Move directory
path= os.getcwd() #Get current directory
print(path)

# C:\Users\hiro22\Desktop\test

Recommended Posts

[Python] Check the current directory, move the directory
Command for the current directory Python
[Python] Check the installed libraries
How to know the current directory in Python in Blender
Check the behavior when assigning Python
Check and move directories in Python
Python Note: Get the current month
[python] Move files that meet the conditions
Start the web server in the current directory
Check the behavior of destructor in Python
Pin current directory to script directory in Python
Check the existence of the file with python
Check if the URL exists in Python
Check the path of the Python imported module
Install the Python module in any directory
Directory move tool to Python package (pycd)
Publish the current directory on the web server
Current directory structure
Python nan check
python grammar check
[python] Check the elements of the list all, any
Pipfile is not created in the current directory
Check if the characters are similar in Python
Check the date of the flag duty with Python
Archive and compress the entire directory with python
Launch an HTTP server in the current directory
Unzip all zip files under the current directory
Check if the string is a number in python
Find the maximum Python
Easy way to check the source of Python modules
[Python] File / directory operations
[Reintroduction to python] How to import via the parent directory
the zen of Python
Python directory operation summary
Domain check with Python
[Python] Split the date
Check Python # type identity
python get current time
Check the asymptotic nature of the probability distribution in Python
Check version with python
Check what the character code is for all files under the directory that is Python and output
[python] How to check if the Key exists in the dictionary
Check the operation of Python for .NET in each environment
Recursively copy files from the directory directly under the directory using Python
Master the type in Python? (When should type check be done)
Check the scope of local variables with the Python locals function.
[Part.2] Crawling with Python! Click the web page to move!
[Note] Import of a file in the parent directory in Python
Get the current date and time in Python, considering the time difference
[Python] Get the script execution directory with an absolute path
Mac Linux Check the capacity directly under a specific directory
python3 Measure the processing speed.
Towards the retirement of Python2
Download the file in Python
Check python coverage with pytest-cov
Find the difference in Python
Compare the Python array-like guys
About the Python module venv
Python --Check type of values
About the ease of Python
How to deal with the problem that the current directory moves when Python is executed from Atom