The path to Python in Xiao Bai _ day1 and the path to python _ day1
- Comparing Python with java, the code is more concise.
Python 3.X Hello World Program:
print("Hello World!")
Java Hello World Program:
public class HelloWorld{ public static void main(String args[]){ System.out.println("Hello World!"); } }
- Python requires no additional points after each sentence of code.
- The annotation Syntax of Python is different from that of java. A single line annotation is a single line annotation # the content to be annotated
Comment on multiple rows using three single quotes or three double quotes ''' comment content '''
- Python variables can be named by underline or camper. However, we recommend that you use underline to name variables. For example, student_number
- When defining a Python variable, you do not need to specify the data type, but you must clearly understand the type of each variable when running the program.
It can be seen that a is an integer, and B is a string because it is an input string. Even if it is both 10, the data type is different.
- Python also supports forced type conversion. The format is: type (variable) to be converted)
- In Python, we recommend that you use indentation instead of curly braces. We recommend that you use four spaces instead of tabs for indentation. Therefore, when using Notepad ++ to write Python code, you can choose Settings> preference> language> tab settings and select "Replace the tab width with a space ". As shown in:
- Python 2.X is encoded in ASCII by default, and ASCII does not support Chinese decoding. Therefore, you must add
#!-*- coding:utf-8 -*-
Or
#coding:utf-8
To replace the encoding table. [Note: The supported Chinese encoding tables include GB2312 (6763 Chinese characters), GBK 1.0 (21003 Chinese characters), GB 18030 (27000 + Chinese characters), and Unicode universal code table]
- Python 3.X is encoded as Unicode by default. Therefore, it supports Chinese characters by default.
End