Ⅱ. Basic data types
#type()
1. Boolean (布尔值)
Ture
False
2. Integer(整型)
3. Float (浮点数)
ⅰ) 取整
a.四舍五入
round()
eg.
b.向上/下取整
math.ceil()
math.floor()
eg.
ⅱ)Convert between int and float
int()
float()
4. String(字符串)
immutable ordered
ⅰ) Basics
a.
+.*
b.
in
not in
ⅱ) Built-in functions
a.
len()
b.
ⅲ) Index
str[]

ⅳ) Slicing
string_x [start: stop: step]
a) positions are inclusive at the start, but exclusive at the stop.
b) step can be specified to specify steps in slicing; the default value of step is 1.
ⅴ) String methods
# All string methods returns new values. They do not change the original string.
a) lower() ,upper()
string.lower()
string.upper()
b> replace()
string.replace(oldvalue, newvalue, count)

c) count()
string.count(value, start, end)

d) find()
string.find(value, start, end)

e) split()
string.split(separator, maxsplit)

f) startswith(), endswith()
string.startswith(value, start, end)
string.endswith(value, start, end)

g) strip()
string.strip(characters)

ⅵ) Conversion between data types
str()
int()
float()
编辑于10月19日 00:07

