Files and Directories again

Let’s continue writing to file that was created in the previous post.

In the code snippet above,

Line number 1: The file path is mentioned in the __file__ variable.

Line number 3: This code represents how to open the file and write the file.

Line number 5: Writing file with few more data.

Line number 7: Writing data to the file using print statement.

Line number 9: del – this command is used to delete the reference of the file from python program.

Please note that the del command doesn’t delete the actual file, but it just removes the reference or the connection to the file from Python program.

Leave a comment

Design a site like this with WordPress.com
Get started