D 11-01 字符串(三) D11-02 (四)
test = '12345678\t9' v = test.expandtabs(6) print(v,len(v))
输出结果 12345678 9 13
test.expandtabs(6)的意思是 每6为一组断开 遇到tab用空格补足6位数,上面78后面就是4个空格,len(v)是所有字符的长度
# \t = tab键,是制表符,tab 符号('\t')默认的空格数是 8。
以下是expandtabs函数实例,例子中的\n为换行符
S = "username\temail\tpassword\nlaiying\tying@q.com\t123\nlaiying\tying@q.com\t123\nlaiying\tying@q.com\t123" v = S.expandtabs(20) print(v)
输出结果:
图中username 、name、password中间有12个空格
test = 'asdf' v = test.isalpha() print(v)
输出结果为 True
判断是否为字母
test = 'a123' v1 = test.isdecimal() v2 = test.isdigit() print(v1,v2)
判断当前是否为数字

浙公网安备 33010602011771号