By default, Python is encoded as UTF-8, and all strings are Unicode strings, and you can define different encodings for your code.
#coding: utf-8#or#-*-coding:utf-8-*-
The reserved word is a keyword and cannot be used as any identifier name. View current version All keywords: keyword module
1 Import keyword #导入keyword模块2 keyword.kwlist
[' False ', ' None ', ' True ', ' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' fi Nally ', ' for ', ' from ', ' global ', ' if ', ' Import ', ' on ', ' is ', ' LA
Single-line Comment: The line that begins with # in code is a comment, and the program does not execute the line when it executes
Multiline Comment: "" "Multiline Comment" "or" "Multi-line Comment"
#这是一个注释 "This is the second comment" "" "" This is the 3rd comment ""
Python has data types: Boolean, Integer, Long, float, string, list, tuple, dictionary, date
- Boolean (BOOL): True/false, 0 of any numeric value, empty string, empty list [], empty tuple (), empty dictionary {} are false, function or method return value is null with false, other data is True.
In [4]: bool (True) out[4]: Truein [5]: bool (False) out[5]: Falsein [6]: bool (0) out[6]: Falsein [8]: BOOL ([]) #空列表 out[8] : Falsein [9]: BOOL (()) #空元组Out [9]: Falsein []: bool ({}) #空字典Out [ten]: Falsein []: bool (1) out[12]: True .................
- Integer (int): Range -2**31 to 2**31-1, which exceeds this range for long integers
- String (str): Enclosed in quotation marks is a string.
#type (): View data type in [+]: type ("Hello World") out[13]: Strin [+]: type ("123") out[14]: str
Standard output, print () The default output is newline, if you want to implement no line break, you need to add end= "" at the end
>>>print ("Hello world!", end= "", "Hello python!") #不换行输出 >>>hello world! Hello python!
"Python" Python basic Syntax encoding