# st = 'jiuge'
# print(type(st))
# print('举例的是%s字符串' % st) # %s 字符串 %d 整数 %f 浮点数
# 一.format() 基本格式:print('{}'.format(st))
# print('我是{}'.format(100))
# 位置匹配
# 1.不带编号
# print('我是{}{}'.format(st, 'we'))
# 2.带数字编号,调换顺序
# a = 'hello'
# b = "world"
# print('{1},{0},{1}'.format(a, b)) # 数字0代表a, 数字1代表是b,从0开始
# 3.带关键字
# print('{t2},{t1}'.format(t1=a, t2='abc'))
# 4.其他用法 了解
# st2 = '{},{}'.format
# print(st2(a, b))
# 二. 格式化 f # 3.6版本后
# print('{},{}'.format(a, b))
# print(f'{b},{a}')
# print(f"{a},{b}")
# 三.字符串编码
# Unicode 万国码
# encode() 编码 将字符串转成Unicode编码
# decode() 解码 将Unicode编码转成字符串
# ty = 'jiuge'
# ty2 = b'jiuge'
# print(type(ty))
# print(type(ty2)) # bytes字节码
# a = '九歌老师'
# a1 = a.encode() # 编码: str类型 -- bytes类型
# print(a1)
# print(type(a1))
# a2 = a1.decode() # 解码: bytes类型 -- str类型
# print(a2)
# print(type(a2))
# 四.常见操作
# 1.find 检测 字符是否包含在 字符串中
# st3 = 'hello world'
# st3 = '哈哈哈哈'
# print(st3.find('l')) # 返回的是索引值
# print(st3.find('e', 3)) # 代表从哪个下标开始寻找, 不包含返回-1
# 2.index 查找索引
# print(st3.index('e', 3)) # 用法跟find一样,找不到会报异常
# 3.count 统计次数
# print(st3.count('o')) # 统计次数
# 4.replace 替换 原字符,新字符
# print(st3.replace('l', 'a'))
# print(st3.replace('l', 'a', 2)) # 指定次数替换
# 5.split 分割
# st3 = 'hello,wor ld'
# print(st3.split(','))
# print(st3.split('l', 2)) # 指定分割次数
# 6.capitalize 首字母大写
st3 = 'hello world'
# print(st3.capitalize())
# 7.startswith 检测以什么开头,是返回True, 否则返回为False
# print(st3.startswith('ll'))
# 8.join连接
print('#'.join(st3)) # join()中是字符串