Get the App
SLTechnology News&Howtos  ›  Development  › 

Common errors and execution methods of python programs

Shulou Source: shulou.com Published: 2022-06-03 18:53:46 09月14日 Update

This article mainly explains "common errors and execution methods of python programs". Friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the common errors and execution methods of python programs.

Common errors:

1 > hand error

2 > write multiple print on one line

Each line of code is responsible for completing an action

3 > indent error

Python is a programming language with strict format.

4 > python 2.x does not support Chinese by default

Python2.x interpreter python

Python3.x interpreter python3 (Chinese supported)

Introduction of Python versions 2.x and 3.x

Python2.x is the past version, and Python3.x is the mainstream version now and in the future.

Python3.x was not designed with backward compatibility in mind

The excessive version provided by Python2.6 basically uses the syntax and library of Python2.x, and takes into account the migration to Python3.0, allowing the use of some Python3.0 syntax and functions.

The Python2.7 launched in mid-2010 was identified as the last version of Python2.x.

If Python3.x cannot be used immediately during development (there are very few third-party libraries that do not support 3.0syntax), it is recommended to develop with the Python3.0 version first, then use Python2.7 to execute it, and do some compatibility processing.

Three ways to execute Python programs

1. Interpreter: python/python3 runs python programs interactively

Advantages

Suitable for learning / verifying python syntax or local code

Shortcoming

The code cannot be saved

It is not suitable to run programs that are too large

Exit the interpreter

Exit ()

Shortcut key ctrl-D

2. Ipython interpreter

IPython is an interactive shell for python, which is much easier to use than the default python shell

Support for automatic completion

Automatic indent

Support for bash shell commands

There are many useful functions and functions built in.

IPython is open source based on BSD.

Version: ipython/ipython3

3. IDE-pycharm of python

At this point, I believe that you have a deeper understanding of the "common errors and execution methods of python programs". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Programs versions errors interpreters support interpretation common ways syntax code learning interaction content functions Chinese development design running practical deeper Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Huawei Apple macOS Linux