Day10-python basic Data Type 1.1 Python 3.5.2 Installation
1,:https://www.python.org/ftp/python/3.5.2/python-3.5.2-amd64.exe
2, the installation process is done directly next.
3, add environment variable; paste the Python installation path into the system variable---path
1.2 Pycharm 5.0.3 Professional Edition installation
1,:http://down10.zol.com.cn/bianchengtools/pycharm503.zip
2, crack the installation process, first adjust the system time to 2038, and then install Pycharm Direct Next, choose to apply 30 days to use, complete the installation, and finally adjust the system time.
3, configure the Python interpreter: Location path: The project is stored interpreter path: Python.exe installation location, create completed.
1.3 operator
The result is a value:
1, arithmetic arithmetic
2, assignment operation
The result is a Boolean value:
3, Comparison operation
4, logical operation
5, Member arithmetic
| Inch |
Returns ture if a value is found in the specified sequence, otherwise fasle |
x in the y sequence; if x returns ture in the Y sequence |
| Not in |
Returns ture if no value is found in the specified sequence, otherwise fasle |
X is not in the y sequence; if x does not return ture in the y sequence |
1.4 Basic data types
1, Digital int
Int
|
Function: Converts a string to a number
A = "123"
b = Int (a)
Print (type (b), B)
Output result: <class ' int ' > 123 |
Bit_lenght
|
Function: Gets the number of bits in the binary
A = 11
v = a.bit_length ()
Print (v)
Output results: 4 |
2, String str
Capitalize
|
Function: Capitalize the first character
S1 = "Liyang"
v = s1.capitalize ()
Print (v)
Output Result: Liyang |
Casefold && Lower
|
Function: Turn all the characters into lowercase, casefold more
S1 = "Liyang"
V1 = S1.casefold ()
Print (v1)
Output Result: Liyang
&&
V2 = S1.lower ()
Print (v2)
Output Result: Liyang |
Center
|
Def center (self, width, fillchar=none)
Function: Set the width, and center the content; 20-generation means total length; * Blank unknown padding, one character, optional
S1 = "Liyang"
V3 = S1.center (20, "Yang")
Print (v3)
Output result: Yangyangyangyang Liyang Yangyangyangyang |
Count
|
Function: To find the number of occurrences of a subsequence in a string; 5 means to start with the first few characters.
S1 = "Liyangliyang"
v = s1.count (' li ', 5)
Print (v)
Output results: 1 |
EndsWith
|
def endswith (self, suffix, start=none, end=none):
function: to what end;
S1 = "Liyang"
V1 = s1.endswith (' y ')
V2 = S1.startswith (' l ')
Print (v1)
Output Result: False
Print (v2)
Output Result: True |
Find
|
def find (self, sub, Start=none, End=none):
Function: From the beginning to find, find the first one, get its position; location range > or >=
S1 = "Liyangliyang"
v = s1.find (' ya ', 7,11)
Print (v)
Output results: 8 |
Index
|
def index (self, sub, Start=none, End=none):
Function: Can't find error, can ignore, direct use Find
S1 = "Liyangliyang"
v = s1.index (' 8 ')
Print (v)
Output Result: Error |
Format
|
def format (*args, **kwargs):
Function: Replaces a placeholder in a string with the specified value
S1 = ' I am {name} '
Print (S1)
v = s1.format (name= ' Liyang ')
Print (v)
Output result: I am {name}
Output result: I am Liyang
&&
S2 = ' I am {0},age{1} '
Print (s2)
v = S2.format (' Liyang ', 28)
Print (v)
Output result: I am {0},age{1}
Output result: I am liyang,age28 |
Format_map
|
Function: Format, the value of the descendant {"name": ' Liyang ', "a": 28}
S1 = ' I am {name}, age {a} '
v = s1.format_map ({"Name": ' Liyang ', "a": 28})
Print (v)
Output result: I am Liyang, age 28 |
Isalnum
|
Function: Determine if the string contains only letters and numbers
S1 = "liyang111"
v = s1.isalnum ()
Print (v)
Output Result: True |
Isalpha
|
Function: Determines whether the character contains only letters, returns true otherwise returns false
S1 = "Liyang"
v = S1.isalpha ()
Print (v)
Output Result: True |
Isdecimal
|
function: If the word breaker contains only numbers, return true otherwise false
S1 = "23423"
v = s1.isdecimal ()
Print (v)
Output Result: True |
IsDigit
|
function: If the word breaker contains only numbers, return true otherwise false
S1 = "23423"
v = s1.isdigit ()
Print (v)
Output Result: True |
Isidentifier
|
Function: Detects if a string is the beginning of a letter
S1 = "werwer234"
v = s1.isidentifier ()
Print (v)
Output Result: True |
Day10-python Basic data types