Python3 Code Snippets

Get Current Date

import datetime as dt
now = dt.datetime.now()
print(now.year)
print(now.month)
print(now.day)

Download File from Internet

import urllib.request
url = 'http://molecularsciences.org'
response = urllib.request.urlopen(url)
mydata = response.read()
mytext = text.decode('utf-8')
print(mytext)