and or not:
优先级:() > not > and > or
x or y x为非0,则返回x;
x and y ,x为真,则返回y;
int--->bool ,非零转化成bool为true,零转化成bool为false。
字符串的索引与切片:
索引:s1 = s[0]
索引下标从0开始。
切片:顾头不顾尾,前开后闭
while 1 比 while true 效率高,因为计算机最终识别的是二进制0和1。
字符串方法
capitalize:首字母大写
upper:字符串全大写
lower:字符串全小写
find:通过元素找索引,找不到为-1
index:通过元素找索引,找不到报错
swapcase :大小写翻转
len:字符长度
replace:字符替换(old,new,count)
isdight:返回是否为数字的bool值
startwith:判断首字母是否为xxx
字符串 str---->bool ,''--->false
"0"--->true
python在编译安装时,可以通过参数,分别用于指定使用2个字节或者4个字节表示一个Unicode字符;python3无法进行选择,默认用ucs4.