Python data type: simple data type; python Data Type
Variable Usage Note string
In python, all strings are enclosed in quotation marks. The quotation marks can be single quotation marks or double quotation marks.
“This is a string”'This is also a string'
Uppercase letters
Implemented using the title Method
1 name = "aaron"2 print(name.title())
Title string reduced write
Use the lower method. When storing data, you often cannot rely on users to provide correct case sensitivity. Therefore, you need to convert strings to lowercase before storing them.
name = "aaron"print(name.lower)
Lower string to uppercase
Use the upper method.
name = "arron"print(name.upper())
Upper merge string
Python uses the plus sign (+) to merge strings.
1 first_name = "aaron"2 last_name = "jim"3 full_name = first_name+" "+last_name
String Merging
The string in python is embodied in the C language as a character array. Each time you create a string, you need to open up a continuous empty block in the memory. Once you need to modify the string, you need to open up space again, every time the "+" icon appears, it will open up a new space.
Add Blank
Use the tab (\ t) and line feed (\ n) to add blank spaces.
1 print("\tptyhon")2 print("\npython")
View Code deleted Blank
- Use the rstrip method to temporarily Delete trailing spaces.
1 value = "python "2 print(value.rstrip())
Rstrip
- Saves the deleted result to the variable to permanently delete the white space at the end of the string.
1 value = "python "2 value_tmp = value.lstrip()3 print(value_tmp)
Variable replacement
Use the rstrip method.
1 value = " python"2 print(value.rstrip())
Rstrip
- Delete blank spaces at both ends
Use the strip method.
1 value = " python "2 print(value.strip)
Strip
The integer int (integer) is on a 32-bit machine. The integer has 32 digits and the value range is-2 ** 31 ~ 2 ** 31-1, I .e.-2147483648 ~ 2147483647
In a 64-bit system, the number of digits of an integer is 64-bit, and the value range is-2 ** 63 ~ 2 ** 63-1, that is,-9223372036854775808 ~ 9223372036854775807 long (long integer) is different from the C language. The Length Integer of Python does not specify the Bit Width, that is, Python does not limit the size of the long integer, but in fact because the machine memory is limited, the long integer value we use cannot be infinitely large.
Note: Since Python2.2, if an integer overflows, Python will automatically convert the integer data to a long integer. Therefore, without the letter L after the long integer data, it will not cause serious consequences.
Floating Point Number
Advanced Literacy http://www.cnblogs.com/alex3714/articles/5895848.html
Floating point numbers are used to process real numbers, that is, numbers with decimals. Similar to the double type in C, it occupies 8 bytes (64-bit), where 52 bits represent the bottom, 11 bits represent the index, and the remaining one represent the symbol. The complex number consists of a real number and a virtual number. The common form is x + yj, where x is the real number of a complex number, and y is the virtual number of a complex number, here, both x and y are real numbers. Note: there is a small number pool in Python:-5 ~ 257 Boolean value true or false 1 or 0