您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
常用:分割、长度、索引、切片 r = (1,2,3,4,5)#只读列表元组 name = "liangml" strip username = input("user:") if username.strip() == "liangml":#strip可以将输入前后的空格都换掉 print("welcome") split names = "liangml","tom","jack" name2 = names.split(",")#split是names拆分开来(得到一个列表) print("|".join(name2))#join是将name2结果以|形式合并到一起 print("" in name)#有没有空格 capitalize print(name.capitalize())#capitalize是将名字的首字母大写 format #format字符串两种赋值方式 msg = "Hello,{name},It's been a long {age} since last time sopke...." #msg2 = msg.format(name="zhangsan",age=111) #print(msg2) msg2 = "lisi{0},dddd{1}" print(msg2.format("liangml",22)) center print(name[2:4]) print(name.center(40,"-"))#center可以指定长度,将字符串两边的长度均匀的分开 find print(name.find("a"))#find查找赋值中有几个包含字符串 isdigit age = input("your age:") if age.isdigit():#isdigit判断他是否为数字 age = int(age) else: print("invalid data type") isalnum name = "liangml!dfs" print(name.isalnum())#不容许复制里面有特殊字符 endswith、startswith print(name.endswith("dfsd")) print(name.startswith("dfsfds")) upper、lower print(name.upper().lower())#upper赋值全部大写,lower全部变小
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。