Cse Material 4
Cse Material 4
C:\Users\dr19m\Desktop\practice program\notebook_prg\file_handling_io\example_file.t
xt
C:\Users\dr19m\Desktop\practice program\notebook_prg\file_handling_io\example_file.t
xt
The os.path.split(path) Method: This method accepts a file path and returns its dire
ctory name as well as the . So it is equivalent to using two separate methods os.pat
h.dirname() and os.path.basename()
The os.path.getsize(path) Method: This method returns the size of the file specified
in the path argument.
The os.listdir(path) Method: The method returns a list of filenames in the specified
path.
Updated Content:
This line is written in w+ mode.
Adding another line.
Appending more content at the end.
Existing Content:
Updated Content:
# Move the file pointer 10 bytes backward from the end (offset=-10, whence=2)
file.seek(-2, 2)
b'The os.path.split(path) Method: This method accepts a file path and returns its di
rectory name as well as the . So it is equivalent to using two separate methods os.p
ath.dirname() and os.path.basename() \r\nThe os.path.getsize(path) Method: This meth
od returns the size of the file specified in the path argument. \r\nThe os.listdir(p
ath) Method: The method returns a list of filenames in the specified path. \r\n'
0
b"Python's syntax emphasizes code readability and clarity, using \nindentation to de
fine code blocks\nThis is another line."
b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x02\x00\x00\x00\x02\x08\x06\x00\x0
0\x00\x1d<\x93\xab\x00\x00\x00\x00IEND\xaeB`\x82'
with open(): It ensures that the file is properly closed after its suite finishes
In [ ]: