How to practice after the python file is written

Scripted programming

Copy the following code to the hello.py file:

print("Hello,Python!");

Execute the script with the following command:

$python./hello.py
hello,python

Use Python's own IDEL

Python comes with an IDE called IDLE.

Content expansion:

Pyc file in Python practice

Introduction to pyc files

. The pyc file contains bytecode compiled from the python source file.

The Python parser tries to load the .pyc file before loading the .py. If it is the latest, there is no need to compile the Python source file again.

. The deletion of the pyc file has no effect

. The pyc file is not large, because it can save the loading time of the python program, it will help to shorten the overall execution time

Method of generating pyc file

Run python -m helloworld.py directly

Use py_compile to generate pyc file python -c "import py_compile; py_compile.compile('helloworld.py')"

Compile all the py files in the directory

import compileall
compileall.compile_dir(r'/path')

So far, this article on how to practice python files is introduced is here. For more related python files how to practice content, please search for ZaLou.Cn's previous articles or continue to browse related articles below. Hope you will support ZaLou more in the future. Cn!

Recommended Posts

How to practice after the python file is written
How to switch the hosts file using python
How to write python configuration file
How to save the python program
How to view the python module
How to learn the Python time module
Where is the directory after python installation
How to use the round function in python
How to use the zip function in Python
How to use the format function in python
How to enter python through the command line
[Practice] How to install python3.6 on Ubuntu system
How to install the downloaded module in python
Python how to move the code collectively right
How to deal with python file reading failure
How to understand the introduction of packages in Python
How does python judge the module installation is complete
How to comment python code
How to learn python quickly
How to uninstall python plugin
How to understand python objects
How to use python tuples
Minimalism is the soul of Python | Python code to find bugs (10)
python how to view webpage code
How to use python thread pool
How Python implements the mail function
How does python change the environment
How to wrap in python code
What is the use of Python
How to omit parentheses in Python
How to install Python 3.8 on CentOS 8
How to install Python 3.8 on Ubuntu 18.04
How to write classes in python
How to filter numbers in python
How to read Excel in Python
How to install Python on CentOS 8
How to solve python dict garbled
How to view errors in python
How to write return in python
How Python operates on file directories
How Python implements the timer function
How to understand variables in Python
How to clear variables in python
How to understand python object-oriented programming
Is python crawler easy to learn
How to use SQLite in Python
A practical guide to Python file handling
How to verify successful installation of python
How to make a globe with Python
How to use and and or in Python
How to delete cache files in python
How to introduce third-party modules in Python
How does python improve the calculation speed
How to save text files in python
Python string to judge the password strength
What is the scope of python variables
How to use PYTHON to crawl news articles
How to write win programs in python
How to run id function in python
How to install third-party modules in Python
How to custom catch errors in python