file detection Flashcards
useful module name:
os
when defining a path to a variable how many slashes should there between each child slash?
2 (\)
what is a dir(directory)?
a folder
Using the module “os” how do you read a text file
With open(‘file name’) as file:
Print(file.read())
How do you write a file using the “os” module?
By changing the ‘r’ argument to a ‘w’ argument
And using the function
File.write(text)
Copyfile()
Copies contents of a file
Copy()
Copyfile() + permission mode + destination can be directory
Copy2()
Copy() + copies metadata (files creation and modification times)
module you use to use to copy files
Shutil module
Arguments in copyfile()
Src,dst
(Arguments in this function)
Deleting a file using the os module
os.remove()
os.remove()
Deletes a file
os.rmdir()
Deletes an empty directory
Shutil.rmtree()
Delete a directory and the files it contains