Using the Python command line

Let's start doing some coding. Whenever I start using a new operating system for development, I like to go through some basics just to get my mind back into it (I'm speaking particularly to those of us who are all too familiar with coding into the wee hours of the morning).

The simplest way to access Python is from the Terminal. We will run a simple program to get started. Load the Terminal from the main toolbar and type python3 at the prompt. Type the following line and hit Enter:

from datetime import datetime

This line loads the datetime object from the datetime module into our instance of Python. Next type the following and hit Enter:

print(datetime.now())

You should see the current date and time printed to ...

Get Internet of Things Programming Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.