惜风不起、唯有努力!
python  str小试牛刀

python str小试牛刀

#字符串截取
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))

发表回复

您的电子邮箱地址不会被公开。