Python number Type
The range represented by the int type is 2147483648 to 2147483648, and numbers beyond this range are treated as long (long shaping)
In Python, you do not need to declare data types beforehand, it is based on specific assignments for the counting data type, for example:
int type
Use the type (variable name) to see what the data type is after the variable is assigned
Numbers beyond the int range
The int type is stored as a long type
You just need to add capital letters to the back.
Plural types are also supported in Python
Plural type
Python String type
# Coding=utf-8 # simple definition simple string test1= hello " print test1 # defines a string containing single quotes Test2= " i don ' t know " print Test2 # Defines a string that contains both single quotes and double quotes, escaping test3= " i Don. t \ "know\" " print test3
\ n line break
# Coding=utf-8 # simple definition simple string mail='totom:\n hello!\n I am jack! ' Print Mail
The above escapes are cumbersome to use, so you can use triple quotes (single quotes and double quotes).
# Coding=utf-8 # simple definition simple string mail="" ToTom: hello! I am jack! ' """ Print Mail
# Coding=utf-8 # simple definition simple string mail="toTom: hello! I am jack! ' " " Print Mail
Manipulating strings
Use variable name [string location number]
# Coding=utf-8 # simple definition simple string strval='abcd'print strval[0]strval[1 ]print strval[1]
The above code prints out a value of a, b
# Coding=utf-8 # simple definition simple string strval='abcd'print strval[0]+strval[1]
Remove ' BCD ' from ' ABCD '
#Coding=utf-8#simple definition of simple stringStrval='ABCDE'#First KindPrintStrval[1:4]#value is BCD#The second KindPrintStrval[:4]#value is: ABCD#take negative indexPrintStrval[-1]#values are: EPrintStrval[-4:-1]#value is: BCD#reverse-Fetch valuePrintStrval[-2:-5:-1]#value is: DCB
Python data type-----numbers & strings