今天是第四天,一如既往的每天都有不会做的内容,然后还是那种你使劲的绞尽脑汁都想不出来的问题,而且还得是别人提示着,讲着,演示着才能明白的,过后自己还得使劲捉摸才能慢慢吃透。一开始还挺顺利的,还以为自己终于能够跟上一点点步伐了呢,谁知道自己高兴太早了,后面的题都不会做。。。每天都是满满的不会做,不行,搞不定,太受挫了。。。。心酸!一想到自己以后还有几十年的人生要过,就不能轻易的投降了,硬着头皮上吧,就像老师说的看不懂就硬看,逼出来就好了。

思维导图:

day4 字符串的操作-LMLPHP

#1,索引和切片 [起始位置:结束位置:步长] 
# s1 = 'python全栈8期' #索引从0开始 [索引(下标,index)]
# print(s1[0])
# print(s1[3])
# print(s1[5])
# print(s1[6])
# print(s1[-1])
#切片 顾头不顾腚
# print(s1[0:6])
# print(s1[6:10])
# print(s1[6:11])
# print(s1[6:])
# print(s1[1:5])
#pto #s1 = 'python全栈8期'
# print(s1[0:5:2])
# print(s1[0:7:3])
#倒取值:加步长
# print(s1[3::-1])
# print(s1[5:0:-2])
# print(s1)
#不变
# s2 = s1[0:6]
# print(s2) ret = 'alexS'
#字符串的使用方法。
# * capitalize 首字母大写,其他的全小写 ret1 = ret.capitalize()
# print(ret,ret1)
# * upper,lower ret2 = ret.upper() ret3 = ret.lower()
# print(ret2,ret3)
''' code = 'A'
your_code = input('请输入验证码,不区分大小写')
if your_code == 'A' or your_code == 'a':
print('您输入的正确')
else:print('请重新输入')
code = 'adeE'.upper()
your_code = input('请输入验证码,不区分大小写').upper()
if your_code == code:
print('您输入的正确')
else:print('请重新输入') '''
# 大小写翻转
# ret4 = ret.swapcase()
# print(ret4)
# ret11 = 'alex+jin wu'
#以特殊符号或者空格隔开,每一个字符串首字母大写 title()
# print(ret11.title())
# * 居中 ret = 'alexS'
# print(ret.center(20))
# print(ret.center(20,'*'))
# *******alexS********
# * 返回bool值 startswith endswith
# ret5 = ret.startswith('a')
# ret5 = ret.startswith('ale')
# ret5 = ret.startswith('alexS')
# ret5 = ret.startswith('l',1,3)
# 切片 # print(ret5)
# ret6 = ret.endswith('S',-2,)
# print(ret6) ret22 = 'alexS,aeaeQ'
# ** count
# ret7 = ret22.count('a')
# ret7 = ret22.count('ale')
# 整体与个体
# ret7 = ret22.count('W')
# 0
# ret7 = ret22.count('a',0,7)
# 切片的count
# print(ret7)
# a2 = "qwaaaaaaaa\taa"
#\t前面的补全
# 默认将一个tab键变成8个空格,如果tab前面的字符长度不足8个,则补全8个,如果tab键前面的字符长度超过8个不足16个则补全16个,以此类推每次补全8个。
# ret8 = a2.expandtabs()
# print(ret8,len(ret8)) ret = 'aleaxS'
# * find 通过元素找到索引(找到第一个元素),找不到返回-1
# ret9 = ret.find('a')
# # ret9 = ret.find('W',0,5)
# print(ret9)
# #index 和find用法一模一样,找不到元素,就会报错
# ret10 = ret.index('w')
# print(ret10)
# * strip 去除字符串前后的空格及你想去除的元素
# ret11 = ' alex '.strip()
# print(ret11)
''' name = 'alex'
username = input('请输入你的用户名:').strip()
if username == name :
print('登录成功') '''
# ret11 = ' alex '.lstrip()
# print(ret11)
# ret11 = ' alex '.rstrip()
# print(ret11)
#一:
# ret12 = 'asldfkjafa'.strip('a')
# print(ret12)
#二:
# ret13 = 'asldfkjafa'.strip('sa')
# print(ret13)
# ret13 = 'asldfkjafa'.strip('salf')
# print(ret13)
# ret14 = 'asldfkajafa'.strip('saWlf')
# print(ret14)
#split * 将字符串分割成列表
# ret15 = 'jinxin alex wusir'
# ret16 = ret15.split()
# print(ret16)
# ret15 = 'jinxin,alex,wusir'
# ret16 = ret15.split(',')
# print(ret16)
# ret15 = 'title tle tlie'
# ret16 = ret15.split('t')
# print(ret16)
# * 替换 replace
# ret18 = '粉红色打开了粉红色级第三粉红色'
# ret19 = ret18.replace('粉红色','嫩绿色',1)
# print(ret19)
# 格式化输出 format
#第一种:
# ret20 = 'name:{},sex:{},身高:{}'.format('alex','ladyboy',178)
# print(ret20)
#第二种:
# ret20 = 'name:{0},sex:{1},身高:{2},name:{0}'.format('alex','ladyboy',178)
# print(ret20)
#第三种:键值对
# ret20 = 'name:{name},sex:{sex},身高:{high},name:{name}'\
# .format(sex = 'ladyboy',high = 178,name='alex')
# print(ret20)
# 判断条件
# name='123'
# print(name.isalnum())
#字符串由字母或数字组成
# print(name.isalpha())
#字符串只由字母组成
# print(name.isdigit())
#字符串只由数字组成 s = 'aelsdskjl'
# s = s[1:]
# print(s)
# print(len(s))
#测量长度
# index = 0
# while True:
# print(s[index])
# index += 1
# if index == len(s):break
#for 变量 in 可迭代对象
# for i in s:
# print(i) s = 'fs4dkjla123fkj2dsa'
count = 0
for i in s:
  if i.isdigit():
    count += 1
  else:print(666)
print(count)

day4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHPday4 字符串的操作-LMLPHP

05-11 15:24