The basic data types in Python are: int (numeric) str (string) bool (Boolean) List (list) Tupel (tuple) dict (dictionary)
Class-to-object relationships
How do I view the class of an object? To get a type by type
" Hey " Print (Type (temp))
Output: <class ' str ' >
How do I see the specific functions of classes and objects in Pycharm?
Method 1:str,ctr+ the left mouse button, find the Str class, view the internal method.
Method 2:b=dir (temp)
Method 3: Through Help
Help (Type (temp))
Method 4: Direct click Method, mouse on the method ctr+ the left mouse button will be automatically positioned to the function.
Basic data type: INT
N1 = 123= 456print(N1+N2)
And
N1 = 123= 456print(N1. __add__(n2))
is the same. The underline method is built-in.
To view the number of bits in the binary:
N1 = 4= n1.bit_length ()print(ret)
The output is 3, indicating that the number of bits in the binary is 3
Method Center:
" Alex " = A1.center (+,'_')
Output to
Count Method:
" Alex is Alph " = A1.count ('A1', 0)print(ret)
The output is:
Endswitch gets the position within the string that is greater than or equal to 0 is less than 2:
" Hello " Print (Temp.endswitch ('e', 0,2)
" hello\t999 " Print (content) Print (Content.expandtabs ()) Print (Content.enpandtabs (20))
" Hello {0}, age {1} " Print = S.format ('Alex', ')print(new1)
{0} {1} placeholder
In the following view of the source code, see for example, Def capitalize (self) has a self method, indicating that the argument is not passed, otherwise you want to write the parameters in parentheses.
If there is xxx = None to indicate the default parameters, if not preach is None, you can pass or do not pass
1. Digital
int (integral type)
On a 32-bit machine, the number of integers is 32 bits and the value range is -2**31~2**31-1, which is -2147483648~2147483647
On a 64-bit system, the number of integers is 64 bits and the value range is -2**63~2**63-1, which is -9223372036854775808~9223372036854775807
An important method in int
Int
2. Boolean valueTrue or False 1 or 03. String
"Hello World"
String Common functions:
- Remove whitespace
- Segmentation
- Length
- Index
- Slice
Important methods of STR
Str
Python Basic data type