#字符串截取 str01 = "niii hao shijie" val01 = str01[1] val02 = str01[0:3] print(val01,val02) #判断变量是否存在某个字符 b = "you" if ("y" in b): print("ok") else: print("on") #字符串格式化 username = "小明" age = 17 address = "北京市" print("my is name: {name},age is: {age}, laizi is addr: {addr}".format(name=username,age=age,addr=address))