Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Tuesday, December 12, 2017

How to create a file, write, read and append to file in python

In the post I will show how to create a File, Write, read and append in python.

Before that lets see the File Modes in Python


File Modes in Python
Mode
Description
'r'
Open a file for reading. (by default)
'w'
Open a file for writing. Creates a new file if it does not exist or deleates the file if it exists.
'x'
Open a file for exclusive creation. If the file already exists, the operation fails.
'a'
Open for appending at the end of the file without replacing it. Creates a new file if it does not exist.
't'
Open in text mode. (by default)
'b'
Open in binary mode.
'+'
Open a file for updating (reading and writing)


Sunday, November 26, 2017

Sunday, June 11, 2017

How to create cron job in ubuntu

In this POST I will show how to create a cron job in Ubuntu. For this we will use python script to print current date and time in log file.

In the previous posts I had shown How to....
OutPut:

2017-06-10 21:35:01.655477
2017-06-10 21:36:01.686346
2017-06-10 21:37:01.711900
2017-06-10 21:38:01.740353
2017-06-10 21:39:01.767497
2017-06-10 21:40:01.792622
2017-06-10 21:41:01.823149