review
while
Uncontrollable cycle all
while+break
This layer out of circulation, out of the loop
while+continue
Out of this cycle
while+else
Cycle is not terminated before execution break
for
Controllable circulation vessel element type String + (data type may iteration)
for+break
for+continue
for+else
Hexadecimal conversion
1. Digital type built-in method
Integer, float
Role: age, height, number, id number
Defined method:
y = 10
id_num = 5201314
x = int(10)
z = int('10')
Built-in methods: addition, subtraction, rounding, modulo,
Storing one or more values: a value
Ordered or disordered: This definition does not
Variable or invariable: immutable
Variable and non-variable (variable value, id unchanged, the variable value of variable, id becomes immutable)
2. String type built-in method
Role: name, sex, say so on
Defined method:
#第一种:'' "" '''''' """"""
#第二种:\
s = b'123456'
print(s)
print('123456'.encode('utf8'))
# \n 换行
s = 'a\na' #碰到斜杠,斜杠与下一个字符在一起有意义
print(s)
# \t 缩进四个空格 \t\t 多个叠加
s = 'a\ta'
# \r 回退上一个打印结果,覆盖上一个打印结果
#在加一个\可使后面的无意义
# r' raw 可使全部\失效
#第三种:r
Built-in method :( only string type to use)
s = 'nick handsome'
# 必须掌握
#1.索引取值
print(s[1])
#2.切片
print(s[4:0:1])#正数表示从左到右
print(s[-4::-1])#负数表示从右到左
print(s[4:0:-1])
#3.for循环
for i in s:
print(i)
#4.strip()(去两端空白)
s1 = ' nick handsome'
print(s1.strip())
s2 = '***nick handsome***'
print(s2.strip('*enmi'))#指定多个字符去除,只要strip里面有的字符进全部干掉
#5.split()(切割)
print(s2,split())#默认以空格切割字符串
print(s2,split('!'))#以指定字符切割
print(s2,split('!',(2.))#2为切割次数
#6.in 或 not in
print('*' in s2)#true
print('$' not in s2)#true
#7.长度len
s2 = 'nick handsome'
print(len(s2))
#需要掌握
#1.lstrip()和rstrip()
#左移右移
#2.split
#3.lwer和upper
#4.starswith和endswith
#5.join 一般和split一起用
#6.replace(替换)
#7.isdigit(纯数字) isalpha(纯字母)
#了解(根据情况)
#find rfind index rindex count
#center ljust rjust zfill expandtabs(针对\t有用)
#captalize swapcase title
Storing one or more values: a value
Ordered or disordered: Ordered
Variable or invariable: immutable