码迷,mamicode.com
首页 > 其他好文 > 详细

str

时间:2018-04-18 00:56:17      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:ase   omr   title   结束   str   none   case   swap   反转   

str [起始索引:结束索引+1:步长]

按照索引找元素/按照切片找元素(顾头不顾尾)/倒着取必须加反向步长【-1】/全部提取[:]

s=‘oldBoy‘
#capitalize 首字母大写,其他小写
# s1=s.capitalize()
# print(s1)


s=‘oldBoy‘
s2=s.upper()
s3=s.lower()
print(s2,s3)

登陆应用:
code=‘womR‘.upper()
your_code=input(‘验证码:‘).upper
if your_code==code:
print(‘验证成功‘)


s4=s.swapcase()
print(s4)
#大小写反转


#title 非字母的元素隔开的每个单词首字母大写
s=‘alex wusir*oldboy3taibai‘
s5=s.title()
print(s5)


s=‘oldboy‘
s6=s.center(30,‘#‘)
print(s6)
#center 剧中 ,长度自己设定,默认填充物NONE
#startswith  endswith
s=‘oldboy‘
# s7=s.startswith(‘oldboy‘)
s7=s.startswith(‘b‘,3,5)
print(s7)


str

标签:ase   omr   title   结束   str   none   case   swap   反转   

原文地址:https://www.cnblogs.com/deja/p/8870874.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!