字符串
1,定义: 单行 多行
2,下标(索引) 0— — -1
3,不允许修改
4,切片
5,内置函数 len() type() max() min()
6,操作
7,遍历
—————————————————————————————
name1 = " 我爱Python ! "
print(name1.isalpha())
Return True if the string is an alphabetic string, False otherwise.
判断字母
print(name1.isdigit())
Return True if the string is a digit string, False otherwise.
判断 数字串
print(name1.isupper())
Return True if the string is an uppercase string, False otherwise.
判断 大写字母
print(name1.islower())
判断小写字母
print(name1.isspace())
Return True if the string is a whitespace string, False otherwise.
判断空字符串
print(name1.lower())
将大写字母转为小写字母
print(name1.upper())
将小写字母转为大写字母
index() 方法检测字符串中是否包含子字符串 str ,如果指定 beg(开始) 和 end(结束) 范围,则检查是否包含在指定范围内
print(",".join(name1))
刘,老,B,根,和,药,匣,子,
将字符串以,分开
s=name1.encode(encoding="utf-8")
print(s)
将name1换成指定编码
print(bs.decode(encoding="gbk"))
解码
print(name2.split(","))
以,分隔 [‘刘老B根和’, ‘药’, '匣子 ']