python-字符串基础

死循环:
while 1==1:
    print('ok',time.time)
    
字节:
UTF8:中文3字节
GBK:中文2字节

input()
input输入类型都是字符串

字符串转换为数字:
n = input()
new_n = int(n)


continue:
终止当前循环,进行下一次循环

break:
跳出当前全部循环

name = “michael jordan”
if "michale" (not) in name:
    print("OK")
else:
    print("ERROR")
    
整体注释:ctrl+?

布尔值也是一种数据类型

v = 1 == 2
print(v)

<>不等于

自加:+=

成员运算:not (in)

true or  ==> true
true and ==> 继续判断
false or ==> 继续判断
false and ==> false

算数运算
    a = 10 + 10
赋值运算
    a = a + 1
比较运算
    > < !=
逻辑运算
    or and 
成员运算:
    not in
    
数据类型:
int
str
list
tuple
bool
dict
set

字符串切片:
test = "asdfgjk"
test1 = test[0:-1]

猜你喜欢

转载自www.cnblogs.com/benchdog/p/9068522.html