My os (python)

Summary for myself Updated from time to time

** I just need to know myself, so the term may be wrong in some places **

!! View

#command
    #Argument option description

What is os used for?

Is it a folder operation?


Module loading

import os
#glob is a bonus
import glob

Frequent operation

Get folders and files

#Get the current directory
os.getcwd()


#Get the file name
os.basename()

#Get absolute path
os.path.abspath()
    __file__  #Path of running file

#Get the folder name
os.path.dirname()

#Get a list of matching filenames
glob.glob(...*.txt)  #...Extension in the path.You can get the file name of txt.




Change folders and files

#Change current directory
os.chdir()

#Create an argument folder
os.mkdir()

#Seems to convert all paths to lowercase
os.path.normase()
    #Path to argument

Check folders and files

#Confirmation of the existence of the folder
os.path.isdir()

#File existence check
os.path.exists()

Recommended Posts

My os (python)
My Numpy (Python)
My sys (python)
My pyproj (python)
My pandas (python)
My str (python)
My pyautogui (python)
Python OS operation
My PySide (Python)
My shutil (python)
My matplotlib (python)
My urllib (python)
My pyperclip (python)
My sklearn (python)
[My memo] python
My ConfigParser (Python)
My Webdriver (Python)
My arcpy (python)
My win32gui (Python)
My python environment memo
My Beautiful Soup (Python)
[My memo] python -v / python -V
Python Tips (my memo)
My python data analysis container
Python
My python data analytics environment
About Python and os operations
Platform (OS) determination by Python
Install Python 3.8 on Ubuntu 18.04 (OS standard)
Install Python 3.8 on Ubuntu 20.04 (OS standard)
I made my own Python library
[Python] My stock price forecast [HFT]
My favorite boto3 (Python) API sample
OS determination by Makefile using Python
Python os related files, subdirectory operations
Install Python 3.9 on Ubuntu 20.04 (OS standard?)
Python My Number verification module released
Determining which OS is running Python
Install Python 2.7 on Ubuntu 20.04 (OS standard?)
kafka python
Python basics ⑤
python + lottery 6
Python Summary
Built-in python
Python comprehension
Python technique
Studying python
Python 2.7 Countdown
Python memorandum
Python FlowFishMaster
Python service
python tips
python function ①
Python basics
Python memo
ufo-> python (3)
Python comprehension
install python
Python Singleton
Python basics ④
Python Memorandum 2