# print (msg.capitalize())# print (msg.center(10,"*")) 以*分割 一共20字节 居中分割# print (msg.endswith(‘d‘))# print (msg.count(‘d‘,0,11)) 统计字符有几个# print (‘{1},{2} {0} {2} ‘.format(‘name‘,‘age‘, "bsk")) 传参## print (msg1.isalnum())# print (msg1.isalpha())# print (msg.istitle()) 首字母是否大写# print (msg.isupper()) 全是大写 msg=‘abc‘#print (msg.ljust(10,‘*‘)) 左对齐 # print (msg.rjust(8,‘‘)) #print (msg.lower()) 变小写# print (msg.upper()) 变大写 # print (msg.rstrip()) 右去空格 lstrip strip#kk=str.maketrans(‘abc‘,‘bsk‘) 翻译#print (msg.translate(kk)) 翻译打印# print (msg.zfill(20))# print (msg.ljust(20))# print (msg.rjust(20))#print.(msg.strip())# msg=5.6# round(4.5) # oldboyage=26## count = 1# while count < 3 :# age= input("Please input your age:")# if age.isdigit():# age = int(getage)# else:# continue# if age>26:# print ("往小里猜")# elif age < 26:# print ("往大里猜")# else:# print ("恭喜你猜对了!")## count += 1### names.remove("字符")# del names[2]# names.pop()# names.index()# names.append() # names = [‘a‘,‘b‘,‘c‘,‘d‘,]# names.append(‘e‘)# names.count(‘b‘)# names
时间: 2024-10-19 22:51:12