old_uname = open(r'C:\Users\Administrator\Desktop\username.txt', 'r').readlines()
count = 0
while count < 3:
username = input("please your username:")
passwd = input("please your passwd:")
for i in old_uname:
if i == username:
print("wolcome to your blogs:{_uname}".format(_uneme=username))
break
else:
continue
else:
count += 1
if count == 3:
continue
print("The password you entered is incorrect!please input again...")
else:
print("三次错误,账号已锁定")
open(r'C:\Users\Administrator\Desktop\lockname.txt', 'a').write(username + '\n')
username = input("username:")
if username.strip('-') == "zhang":
print(username.strip('-'))
print("welcome %s to beijing" % username)
list11 = "welcome to beijing"
list2 = list11.split()
print(list2) # ['welcome', 'to', 'beijing']
list3 = ":".join(list2) + '\n' # welcome:to:beijing
list4 = " ".join(list2) # welcome to beijing
print(list3, list4)
name = "mr,niu"
print("," in name)
name1 = "mr niu"
print(" " in name1)
print(name[2:4])
men = "my name is {name}, age is {age}"
all = men.format(name="niu", age=23)
men1 = "my name is {0}, age is {1}"
all1 = men1.format("niu", 23)
print(all1)
fill = "niu"
fill.isdigit() # 判断是不是数字
fill.endswith('') # 判断是不是以指定字符串结尾
fill.startswith('') # 判断是不是以指定字符串开头
fill.upper() # 批量转换成大写 fill.lower() # 批量转换成小写 fill.capitalize() # 第一个字母大写,其他都小写 fill.title() # 每个单词的首字母大写,其他都小写
print(fill.center(20, '='))