博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
字符串
阅读量:6291 次
发布时间:2019-06-22

本文共 2348 字,大约阅读时间需要 7 分钟。

>>> a='abcdefg'>>> a'abcdefg'>>> a[::-2]'geca'>>> a[::]'abcdefg'>>> a[::-1]'gfedcba'>>> a = 'abcdef'>>> a'abcdef'>>> a[::-1]'fedcba'>>> a'abcdef'>>> a[4:3]''>>> a[4:3:-1]'e' >>> mystr = 'hello world wanglinjie linjie w_linjie'>>> mystr.find("linjie")16>>> mystr.find("linjie",0,10)-1>>> mystr.count("linjie")3 >>> mystr.replace("linjie","LinJie")'hello world wangLinJie LinJie w_LinJie' >>> mystr.replace("linjie","LinJie",1)'hello world wangLinJie linjie w_linjie' >>> mystr.split(" ")['hello', 'world', 'wanglinjie', 'linjie', 'w_linjie'] >>> mystr.split(" ",2)['hello', 'world', 'wanglinjie linjie w_linjie'] >>> mystr.split(" ",3)['hello', 'world', 'wanglinjie', 'linjie w_linjie'] >>> mystr.capitalize()'Hello world wanglinjie linjie w_linjie' >>> mystr.title()'Hello World Wanglinjie Linjie W_Linjie' >>> mystr.startswith("hello")True>>> mystr.startswith("Hello")False>>> mystr.endswith("jie")True>>> mystr.endswith("Jie")False>>>

 

>>> Mystr=ystr = 'Hello World Wanglinjie Linjie W_Linjie'>>> Mystr.lower()'hello world wanglinjie linjie w_linjie'>>>

 

>>> Mystr=ystr = 'Hello World Wanglinjie Linjie W_Linjie' >>> Mystr.lower()'hello world wanglinjie linjie w_linjie' >>> Mystr.upper()'HELLO WORLD WANGLINJIE LINJIE W_LINJIE' >>> Mystr.ljust(10)'Hello World Wanglinjie Linjie W_Linjie' >>> my = 'wang'>>> my.ljust(10)'wang      '>>> mystr.rjust(10)'hello world wanglinjie linjie w_linjie'>>> my.rjust(10)'      wang'>>> mystr.center(10)'hello world wanglinjie linjie w_linjie'>>> my.center(10)'   wang   '>>> my.lstrip()'wang'>>> a = '     linjie     '>>> a.lstrip()'linjie     '>>> a.rstrip()'     linjie'>>> a.strip()'linjie'>>>

 

>>> mystr'hello world wanglinjie linjie w_linjie'>>> mystr.rfind("linjie")32>>> mystr.partition("linjie")('hello world wang', 'linjie', ' linjie w_linjie')>>> mystr.rpartition("linjie")('hello world wanglinjie linjie w_', 'linjie', '')

 

 

>>> mystr = 'abc'>>> mystr.isalpha()True>>> mystr.isdigit()False>>> mystr1 = '123'>>> mystr1.isalpha()False>>> mystr1.isdigit()True>>> mystr2 = 'abc123'>>> mystr2.isalnum()True>>> mystr1.isalnum()True>>> mystr.isalnum()True>>> mystr3 = ' '>>> mystr3.isalnum()False>>> mystr3.isspace()True

 

 

>>> mystr = ' '>>> li = ["my","name","is","linjie"]>>> mystr.join(li)'my name is linjie'>>> a = '_'>>> a.join(li)'my_name_is_linjie'>>>

 

转载于:https://www.cnblogs.com/wanglinjie/p/9108433.html

你可能感兴趣的文章
玩转Edas应用部署
查看>>
music-音符与常用记号
查看>>
sql操作命令
查看>>
zip 数据压缩
查看>>
Python爬虫学习系列教程
查看>>
【数据库优化专题】MySQL视图优化(二)
查看>>
【转载】每个程序员都应该学习使用Python或Ruby
查看>>
PHP高级编程之守护进程,实现优雅重启
查看>>
PHP字符编码转换类3
查看>>
rsync同步服务配置手记
查看>>
http缓存知识
查看>>
Go 时间交并集小工具
查看>>
iOS 多线程总结
查看>>
webpack是如何实现前端模块化的
查看>>
TCP的三次握手四次挥手
查看>>
关于redis的几件小事(六)redis的持久化
查看>>
webpack4+babel7+eslint+editorconfig+react-hot-loader 搭建react开发环境
查看>>
Maven 插件
查看>>
初探Angular6.x---进入用户编辑模块
查看>>
计算机基础知识复习
查看>>