Getting Started with Python
This article will introduce how to start and run Python scripts.
1. Confirm Python Version
Assuming you have already installed Python, enter the following content in the Linux command line to confirm the Python version:
Bash | |
---|---|
1 |
|
Output:
Text Output | |
---|---|
1 |
|
In the latest version of DataFlux Func (Automata), the Python version is 3.8.10
2. Enter Python Command Line
Python includes an interactive command line where you can execute simple Python scripts directly in the interactive command line.
Enter the following content in the Linux command line to access the Python command line:
Bash | |
---|---|
1 |
|
Output:
Text Output | |
---|---|
1 2 3 4 |
|
At this point, the cursor is after the prompt >>>
, and you can now write Python scripts. Each line of Python script executes after pressing Enter, such as:
Python | |
---|---|
1 |
|
Output:
Text Output | |
---|---|
1 |
|
In subsequent documents, Python code will not include the prompt >>>
at the beginning
3. Writing Python Scripts in a File
We can also write the above Python script into a hello.py
file and execute it using the python
command.
Bash | |
---|---|
1 |
|
It can also be changed into an executable script as follows:
Python | |
---|---|
1 2 |
|
After making it executable, call and run it directly:
Bash | |
---|---|
1 2 |
|
3.1 Print Function print
The print function in the example above is mainly used to output information, such as the print('Hello, World!')
which means "output the Hello, World! text in the terminal".
You will see more use cases in subsequent articles.