One, python understanding
Python is a scripting language. Python is an object-oriented interpreted computer programming language. The grammar is concise and clear, and one of its features is to force whitespace as a statement indentation.
advantage:
Cross-platform, glue language, open source and free, rich library.
Disadvantages:
The running speed is slow, the code cannot be encrypted, scenarios, data analysis, network applications, and writing simple crawlers.
1、 IDLE
IDLE is python shell, shell means "shell", which is a way to interact with programs by typing text, just like the cmd windows in windows, they are all shells, and you can use them to give commands to the operating system. Use the IDLE shell to interact with python.
**2、 What does print() do? **
print() will display some text in the output window.
3、 BIF
BIF is Built-in Functions, built-in functions. In order to facilitate programmers to quickly write script programs, python provides a wealth of built-in functions that can be called directly.
For example, the function of print() is to "print to screen", and the function of input() is to receive user input. python3 provides 68 BIFs.
Enter dir (builtns) in python or IDLE to see the list of built-in methods provided by python (note that there are two underscores before and after builtins).
Two, python common syntax
**1、 The multiplication sign in python is * (asterisk). **
2、 Embed a double quotation mark in a string: Use a backslash () to escape the double quotation mark: ", or use single quotation marks to enclose the string.
**3、 Two completely different things cannot be added together in python, such as numbers and text. **
**4、 Add \n to the statement to wrap. **
You cannot add \ to the end of the original string, just add r in front.
**5、 The print statement uses the print() function. **
**6、 Comparison operator: **
A statement that is too long can be broken up into several lines using backslashes or parentheses.
Use semicolons to separate statements.
7、 loop statement:
**8、 Conditional branch: **
9、 Introducing foreign aid:
10、 Stitching
In some programming languages, you can "add" two strings together, for example:'I' +'Love' +'You' will get'I LoveYou'. In python, this practice is called concatenating strings.
**11、 Do you think'love' is the same as'Love'? **
Not the same, love and Love are completely different names, so be careful when programming.
If the identifier can be used in the code after it has been assigned (the python variable does not need to be declared first), the direct use of the unassigned identifier will cause a runtime error.
**12、 "=" and "= =" have different meanings. **
**= Indicates assignment. Variables must be assigned before using them. Variable names cannot start with numbers. Variable names can include letters, numbers, and underscores. **
**== Used to determine whether the values of two objects are equal. **
**Python does not allow assignment in if conditions, so if c=1: an error will be reported! **
**Note: **Indentation is the soul of python. The strict requirements of indentation make python code very streamlined and hierarchical. If you enter the colon ":" in the correct position, IDLE will automatically indent the next line.
Recommended Posts