python保留子_python ftp断点续传Python取子字符串方法

Python取子字符串方法

要求:从字符串中

www.002pc.com对《python ftp断点续传Python取子字符串方法》总结来说,为我们python基础很实用。

sfsfsd345#-3sfsfsd3.4me取345#-3出来Python自定义函数的写法如下所示:>>> ================================ RESTART ================================

>>> def getsubstr(txt_s):

#处理换行符问题

t=txt_s

findex=txt_s.find('#')

s_len=len(txt_s)

t=t[0:findex]

dkbh=''

bh_s=''

for a in t:

#获取是数字 中划线 下划线的子字符串

if(a.isdigit()==True or a=='-' or a=='_'):

if(dkbh==''):

dkbh=a

else:

dkbh+=a

s=txt_s[findex+1:findex+2]

if(s=='-'):

s=txt_s[findex+1:s_len]

for b in s:

if(b.isdigit()==True or b=='-' or b=='_'):

if(bh_s==''):

bh_s=b

else:

bh_s+=b

else:

break

dkbh+='#'+bh_s

return dkbh>>> print getsubstr('sfsfsd345#-3sfsfsd3.4men')

345#-3

>>>

>>> ================================ RESTART ================================

>>> def getAreaVal(txt_s):

findex=txt_s.find('#')

s_len=len(txt_s)

rb=''

bh_s=''

s=txt_s[findex+1:findex+2]

if(s=='-'):

s=txt_s[findex+1:s_len]

for b in s:

if(b.isdigit()==True or b=='-' or b=='_'):

if(bh_s==''):

bh_s=b

else:

bh_s+=b

else:

break

q=txt_s[findex+1:s_len]

for c in q:

if(c.isdigit()==True or c=='-' or c=='_' or c=='.'):

if(rb==''):

rb=c

else:

rb+=c

else:

continue

return rb.replace(bh_s,'')

>>> print getAreaVal('sfsdfd45#-2sfdfs45.6men')

45.6

>>>

更多:python ftp断点续传Python取子字符串方法

https://www.002pc.comhttps://www.002pc.com/python/4291.html

你可能感兴趣的Python,取子,字符串,方法

No alive nodes found in your cluster

0踩

0 赞

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值