Thursday, March 5, 2015

Python Programming: 1 Basic Python Scripts


To Know Today's date & Time:
>>> from datetime import date
>>> now = date.today()
>>> now
datetime.date(2015, 3, 13)
>>>

Reading files:
#!/usr/bin/python

#Open a file
fo = open("/root/divakar/marks.txt", "rw+")
print "marks:", fo.name
line=fo.read()
print "Read Line: %s" % (line)

# Close opend file
fo.close()
 -------------------

No comments:

Post a Comment