摘要: #非空即真,非零即真a =""b=[]c={}d=0f=None#判断username是否为空username=input("用户名:").strip()(1)# if len(username)==0:# print("输入不能为空")(2)#True:# if username:# print( 阅读全文
posted @ 2021-05-11 16:44 迷m 阅读(84) 评论(0) 推荐(0)
摘要: # a.join()#用来连接字符串的stu_list=['xiao','xiaobai','xiaolan']stu_str=''.join(stu_list)#print(stu_str)stu_str='*'.join(stu_list)#用*号连接字符串print(stu_str) 阅读全文
posted @ 2021-05-11 16:01 迷m 阅读(360) 评论(0) 推荐(0)
摘要: # a.join()# a.split()分割字符串 stus ='xiaohei\nxiaobai xiaolan'print(stus.split(','))#分割字符串的,分割之后会返回一个listprint(stus.split())#如果没有指定字符串,那么就按空字符来分割 阅读全文
posted @ 2021-05-11 16:00 迷m 阅读(107) 评论(0) 推荐(0)
摘要: # a.zfill()#补0前面# num ="05"# print(num.zfill(3))#5代表总共有几位数 # a.replace()#替换字符串# mag = "nihao.nice to m y"# new_mag = mag.replace("nihao",'heoll').repl 阅读全文
posted @ 2021-05-11 15:52 迷m 阅读(63) 评论(0) 推荐(0)
摘要: # a.startswith()#判断字符串是否以xx开头msg ="你好"print(msg.startswith("你好"))# a.endswith()#判断字符串是不是以xx结尾file_name ="a.jpg"print(file_name.endswith(".jpg")) 阅读全文
posted @ 2021-05-11 15:49 迷m 阅读(1589) 评论(0) 推荐(1)
摘要: #a.format()## msg ="你好,{name},今天日期是{date}".format(name="xiaohei",date="2021-4-28")# msg2="你好,{},今天日期是{}".format("xiaohei","2021-4-28")## # a.format_ma 阅读全文
posted @ 2021-05-11 15:44 迷m 阅读(443) 评论(0) 推荐(0)
摘要: # a.count()#统计字符串中出现的某个字符串的个数# a.isdigit()#判断字符串,是否为整数,是就返回true,否就返回false# a.isalnum()#如果字符串不包含特殊符号,就返回true# a.isalpha()#如果字母或者汉字就返回true,其它返回false 阅读全文
posted @ 2021-05-11 15:41 迷m 阅读(249) 评论(0) 推荐(0)
摘要: # a.lower()#把字符串都变成小写# a.upper()#把字符串都变成大写 阅读全文
posted @ 2021-05-11 15:39 迷m 阅读(155) 评论(0) 推荐(0)
摘要: # a.strip()#去掉字符串两边的空格和换行符,中间的不会# a.lstrip()#去掉左边# a.rstrip()#去掉右边 阅读全文
posted @ 2021-05-11 15:38 迷m 阅读(1027) 评论(0) 推荐(0)
摘要: 定义一个参数:a ="abcdef" a.index()#找下标 a.find()#找下标 两者之间的区别: print(a.index("b1"))#如果找元素不存在,会报错 print(a.find("b1"))#如果找元素不存在,会返回-1 阅读全文
posted @ 2021-05-11 15:34 迷m 阅读(3307) 评论(0) 推荐(0)