摘要: .find() .index() .rfind() .count() s='hello world'print(s.find('a')) # 查找指定字符串,找不到返回-1print(s.find('l',3,4)) # 需输入开始查找的索引和结束的索引,找到显示索引,找不到则返回-1,不会报错pr 阅读全文
posted @ 2020-05-02 19:41 huangjunlong 阅读(135) 评论(0) 推荐(0)
摘要: .ljust(width) .rjust(width) .center(width) .zfill(width) a='1 3 4' print(a.ljust(10)) # 获取固定长度,左对齐,右边不够用空格补齐 print(a.rjust(10)) # 获取固定长度,右对齐,左边不够用空格补齐 阅读全文
posted @ 2020-05-02 19:22 huangjunlong 阅读(91) 评论(0) 推荐(0)
摘要: .upper() .lower() .swapcase() .capitalize() .title() a='fheGifHF'print(a.upper()) # 全部大写print(a.lower()) # 全部小写print(a.swapcase()) # 大小写互换print(a.capi 阅读全文
posted @ 2020-05-02 19:10 huangjunlong 阅读(125) 评论(0) 推荐(0)