mirror of
https://github.com/rasbt/python_reference.git
synced 2025-01-18 23:37:07 +00:00
file ops
This commit is contained in:
parent
c7b87b749d
commit
38135aa7b8
|
@ -56,6 +56,8 @@ os.path.isabs('./some_file.txt') # returns False (not an absolute path)
|
|||
os.path.abspath('./some_file.txt')
|
||||
|
||||
|
||||
|
||||
|
||||
# create and delete files and directories
|
||||
os.mkdir('./test') # create a new direcotory
|
||||
os.rmdir('./test') # removes an empty direcotory
|
||||
|
@ -66,3 +68,6 @@ shutil.rmtree('./test') # removes directory (empty or not empty)
|
|||
os.rename('./dir_before', './renamed') # renames directory if destination doesn't exist
|
||||
shutil.move('./dir_before', './renamed') # renames directory always
|
||||
|
||||
shutil.copytree('./orig', './copy') # copies a directory recursively
|
||||
shutil.copyfile('file', 'copy') # copies a file
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user