Zero-based learning python (a)

Recently result of the need to start learning python language. Learn and share with you the experience. There are insufficient or the wrong place, please exhibitions.

 

Environment to build

Operating environment: windows7 system. I chose python environment pycharm integrated environment. Eliminating the need to build some of its own operating environment variables, and so on.

Development Tools: PyCharm 2019.1.2. python development tools are many. Personally like python style, so I chose Pycharm

Download link: https://pan.baidu.com/s/1IyCAplqj-1Ozdq67RpJ-rw extraction code: w7vo 

The latest version can also go to the official website to download; https: //www.jetbrains.com/pycharm/download/#section=windows

Mainly because I enjoy python web crawler, so I aimed to achieve this function began studying reptiles.

indentation:

python entire frame format are indented to show his inclusion and hierarchy, you do not want other languages ​​can be enclosed in parentheses. An indentation equal to four spaces. Of course pycharm this tool. So you can press a tab key on it.

Indent approach the theme used in (naming method) if, while, for, def, class (the class name) and other key inside. These keywords must colleague back with a colon (:) Here is used to describe a whole body

E.g:

if 1<2:
    print(1)

def main():
    print(1)
View Code

Comment:

Notes python language using the "#" to single-line comments. Note bulk single quotes, or three by three double quotes. ( '' '' '')

variable:

python language allows the use of uppercase letters, lowercase letters, numbers, underscores (_) and kanji characters and their combinations to the variable name, but the name of the first character can not be a number, intermediate spaces can not appear, there is no length limit. Note that the python language is very sensitive to the case. Such as python and Python on behalf of two different variables.

python variable declarations do not need to be defined, but direct assignment. According to this variable to determine what is behind the assignment type. For example i = 1, i = "abc", i = [ 'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'purple']

Assignment:

python has a very flexible assignment expressions. For example: a = 1, b = 2 can ctrip a, b = 1,2.. You can also make the call variable values. a, b = b, a

Quote:

referenced using python import keyword. Import function is required before a reference library. FIG pycharm introducing method,

 

 Select "File" === "Settings

 

Click on the red box plus sign

 

 Search you need to load third-party libraries, and then click Install Package to install

A basic input and output functions:

Before INPUT (), get user input, INPUT () function may comprise suggestive text, for example: input ( "Enter a positive integer greater than 0 and less than 10")

the eval (), which is a very important function python, which can be parsed to a method and performs python expression string, the execution result is output. For example: a = eval ( "1 + 2") results print (a) is 3. eval function and input function is usually used together for obtaining user input

print (), he uses three, first a direct print ( "hello world"), the second print (variable 1, variable 2, variable 3), it will simultaneously outputs three variables, the third print ( "digital and digital {{}} is the product of {}". format (2, 3, 2 * 3)) product of the number 2 and number 3 is 6, for mixing the output of the variable value string

end can have the print function parameters. For example: print (24, end = "***"), then the content it entered: 24 ***. end represents the mosaic of meaning. Additional end parameter to a comma after the number of money value.

 

 

Please indicate the source.

Guess you like

Origin www.cnblogs.com/xiaoxiaolee/p/11825332.html