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 in the Linux command line to confirm the Python version:
Bash | |
---|---|
1 |
|
Output:
Text Output | |
---|---|
1 |
|
In the latest version of DataFlux Func, 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 within the interactive command line.
Enter the following 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 now you can 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. Write 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 modified into an executable script as follows:
Python | |
---|---|
1 2 |
|
And after making it executable, call it directly:
Bash | |
---|---|
1 2 |
|
3.1 Print Function print
The print function in the previous example is mainly used to output information, like the print('Hello, World!')
which means "output the text Hello, World! to the terminal."
You will see more use cases in subsequent articles.