python基础 day4

1,昨日内容及作业讲解
ascii:字母,数字,特殊字符:1个字节,8位
Unicode:16位 两个字节 升级 32 位 四个字节
utf-8:最少一个字节 8位表示。 英文字母 8位 1个字节
欧洲16位,2个字节
中文24位,3个字节
gbk:中文2个字节,英文字母1个字节。

int:bit_lenth()
bool:True False
str: str --->bool :bool(str): ''--->False
str:
s = 'alexsb'
s1 = s[1]
s2 = s[1:3]
s3 = s[0:] s[:]
s4 = s[0:-1]
s5 = s[0:3:2]
s6 = s[2::-2]

captlze首字母大写
upper()全大写
lower()全小写
find通过元素找索引,找不到-1
index()通过元素找索引,找不到 报错
swpcase 大小写翻转

repalce(old,new,count)
isdigit() 返回bool值
isapha()
isnumpha()
startswith endswith
title 首字母大写
center()居中
strip()lstrip rstrip
split
format 格式化输出
{}
{0}{1}{2}{0}
{name}{age}{hobby} name= age+ hobby


len() 长度
count 计数

for i in 可迭代对象:
pass


2,列表
增   append  insert  extend

删  pop  remove  clear  del

改  li[索引]='被修改的内容'  li[切片]:'被修改的内容'

查  for i in   li[索引]
列表的循环
列表的嵌套
3,元祖

 

#列表转换成字符串 S.join(self)

  字符串转成列表 split(self)

 

posted @ 2019-03-13 21:44  遗忘天际  阅读(86)  评论(0编辑  收藏  举报