学Python的第七天
今天学习DBA有点乏,所以Python学的不是很多熬!!!
但是不管多苦多累Python不会放弃!!
虽然我是运维!
#!/usr/bin/env python3 # -*- coding:utf-8 -*- #expandtabs,断句20(\t类似于char字符特性),可用于表格类制作. test = "username\temail\tpassword\ncsdnak\tcsdnak@qq.com\t123\ntomcat\ttomcat@qq.com\t123\ngithub\tgithub@qq.com\t123" v = test.expandtabs(20) print(v) #判断是否是字母、汉子(Python中判断真假:True/False与Shell中$0:0/非零性质类似) test = "csdn阿坤" v = test.isalpha() print(v) #判断是否为数字,isdecimal只支持十进制数字,isdigit更强大支持十进制数字以及②类型数字,isnumeric最强大可支持汉子二 test = "2②二" v1 = test.isdecimal() v2 = test.isdigit() v3 = test.isnumeric() print(v1,v2,v3) #字母,数字,下划线:标识符 ,def class也符合 a = "def" v = a.isidentifier() print(v) #是否包含不可显示的字符,例:制表符\t,换行符\n test = "csdn\tak" v = test.isprintable() print(v) #判断是否全部是空格或者有东西却看不见,例如\n,\t test = "\n" v = test.isspace() print(v) #判断是否为标题 test = "Return True if all cased characters in S are uppercase and there is" v1 = test.istitle()#判断是否为标题(标题准则:每个单词首字母必须是大写) print(v1) v2 = test.title()#把字符转换为标题类型 print(v2) v3 = v2.istitle()#经过转换后判断为True成立 print(v3) #join,字符串元素拼接*****(重要等级为※) test = "折戟沉沙铁未销" t = ' ' v1 = t.join(test) print(v1) v2 = " ".join(test) print(v2) #just(个数,符号),填充(left/right) test = "csdnak" v1 = test.ljust(20,"*") print(v1) v2 = test.rjust(20,".") print(v2) #zfill(个数)填充,只能用0来填充并且填充永远是左边(一般不用)just足以。 v3 = test.zfill(20) print(v3) #判断小写并转换 test = "Alex" v1 = test.lower()#全部转换成小写 v2 = v1.islower()#判断是否全部是小写 print(v2) #判断大写并转换 v3 = test.upper()#全部转换成大写 v4 = v3.isupper()#判断是否全部是大写 print(v4)