File Operations
I LOVE DOING THIS :)
File Input and Output in Python really helps us to read - write and store persistent data
open(file_name, access_mode)
read(byte_count)
write(data)
close()
os.rename()
os.delete()
write()
- If the file doesn't exists then it gets created and if it exists it will be over-written
TypeError: write() argument must be str, not int
Incase, if we wanna append()
, we can simply use the append call and its descriptor
To read
the file we can use the read syscall
line.strip()
will automatically append the "\n" new line character in the end
Exercise Question
Read /var/log/messages
Find all the logs in it which pertain to USB and grep them out selectively
Last updated