Home > Database > Mysql Tutorial > body text

Learning Python in anger - Part 1 - Understanding Python

黄舟
Release: 2016-12-20 16:54:22
Original
901 people have browsed it

After reading the programmer leveling guide, I discovered my own shortcomings. Since I have already learned C++, I decided to write down the learning process of python without knowing C++.

Python is an interpreted, interactive and object-oriented scripting language. It was invented by Guido van Rossum in 1989 and is also known as the glue language because it can easily connect other languages ​​together. It was developed from ABC and combined with ideas from SmallTalk, C++ and other languages. The source code also follows the GPL.

The author is using Python 2.7 on Linux. When setting up the environment, Ubuntu will install it by default.

Start the coding routine - "Hello, world!".

Python has two programming methods.

The first type is interactive programming: that is, programming in which you can get the running results while coding, as shown in the figure

Learning Python in anger - Part 1 - Understanding Python

The second type is scripted programming: that is, writing code in a document and saving the document as Files with the suffix py are run through the python command, as shown in the figure

Learning Python in anger - Part 1 - Understanding Python

Python identifiers: The rules are similar to C++, but there is a little difference. For example, identifiers starting with an underscore like "_ex" are generally private members, with both sides The underlined ones are generally identifiers of Python-specific methods, such as "_init_()" which defaults to the constructor of the class.

Python’s reserved words: http://laiguowei2004.blog.163.com/blog/static/3682900020110611747142/

Python’s code blocks: controlled by indentation, the same code block must be indented the same.

Python’s line control: Python usually uses lines to control statements, and a newline indicates the end of the statement.

Python's ";": You can use a semicolon to display multiple lines of statements in one line, such as

ans = a; ans = ans + b; ans = ans + c;

Python's "": You can use One line of statements displays multiple lines

ans = a +
b +
c

Python quotation marks: Python supports ', ", ''' and """ to define strings, as long as the left and right sides are the same. Such as

name = 'wyp'name = "wyp"name = '''wyp'''name = """wyp"""

Python's "#": used at the beginning of comments, only line comments are supported , comments are not supported, such as

name = 'wyp'#this is a string

Python's ":": used to form a code group (a group of consecutive statements with the same indentation), as shown in the following code, with The first sentence of ":" and the following code group form a clause (clause)

if name == 'wyp' :
ans = ans + 1else:
ans = ans - 1

The above is how to learn Python in anger— —Part 1—Understand the content of Python. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!