代码

#str内部功能
name=' aK am\til.L iu'
age=18
num=-11
ab='#'
ac=('1','2','3','4','5','6','7')
print(dir(name))
print(name.capitalize())#capitalize(self):首字母大写
print(name.center(30,'#'))#center(self, width, fillchar=None): 内容居中,width:总长度;fillchar:空白处填充内容,默认无
print(name.count('i'))#count(self, sub, start=None, end=None):子序列个数
'''
decode(self, encoding=None, errors=None):解码
encode(self, encoding=None, errors=None):编码,针对unicode
'''
print(name.endswith('u'))#endswith(self, suffix, start=None, end=None):是否以xxx结束 startswith(self, prefix, start=None, end=None):是否起始
print(name)
print(name.expandtabs(3))#expandtabs(self, tabsize=None):将tab转换成空格,默认一个tab转换成8个空格
print(name.find('i'))#find(self, sub, start=None, end=None):寻找子序列位置,如果没找到,返回 –1
print(name.find('b'))
#format(*args, **kwargs):字符串格式化,动态参数,讲函数式编程时细说
print(name.index('il'))#index(self, sub, start=None, end=None): 子序列位置,如果没找到,报错
print(name.isalnum())#
'''
isalnum(self): 是否是字母和数字
isalpha(self):是否是字母
isdigit(self):是否是数字
islower(self): 是否小写
translate(self, table, deletechars=None):转换,需要先做一个对应表,最后一个表示删除字符集合
'''
print(ab.join(ac))#join(self, iterable):连接
print(name.ljust(30,'$'))#ljust(self, width, fillchar=None):内容左对齐,右侧填充 zfill(self, width):方法返回指定长度的字符串,原字符串右对齐,前面填充0。
print(name.lower())#lower(self):变小写 swapcase(self):大写变小写,小写变大写
print(name.lstrip())#lstrip(self, chars=None):移除左侧空白 strip(self, chars=None):移除两端空白
print(name.partition('m'))#partition(self, sep):分割,前,中,后三部分
print(name.replace('am', 'qqqqqq'))#replace(self, old, new, count=None):替换
print(name.split())#split(self, sep=None, maxsplit=None):分割, maxsplit最多分割几次
print(name.splitlines())#splitlines(self, keepends=False):根据换行分割

结果

['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
ak am il.l iu
####### aK am il.L iu########
2
True
aK am il.L iu
aK am il.L iu
8
-1
8
False
1#2#3#4#5#6#7
aK am il.L iu$$$$$$$$$$$$$$$
ak am il.l iu
aK am il.L iu
(' aK a', 'm', '\til.L\tiu')
aK qqqqqq il.L iu
['aK', 'am', 'il.L', 'iu']
[' aK am\til.L\tiu']

最新文章

  1. 简单的数据库设计及使用(FMDB)
  2. openssl pem 生成公钥和私钥及文件
  3. 【浅析】IMU代码
  4. c# xml的增删改查操作 xmlDocument 的用法
  5. pyqt5 笔记(二)实现http请求发送
  6. SaaS系列介绍之十五: SaaS知识重用
  7. 自定义UICollectionViewLayout 实现瀑布流
  8. 笔试题:金额转换,阿拉伯数字的金额转换成中国传统的形式如:(¥1011)->(一千零一拾一元整)输出
  9. 《Django By Example》第九章 中文 翻译 (个人学习,渣翻)
  10. SQL中partition关键字的使用
  11. 一套代码小程序&Web&Native运行的探索01
  12. centos6.5 开机自动挂载硬盘
  13. JavaSE学习总结(二)——Java语言基础
  14. 放棋子|2012年蓝桥杯B组题解析第七题-fishers
  15. CPU、OpenGL/DirectorX、显卡驱动和GPU之间的关系
  16. c标签取数组中的对象值的2种方法
  17. gradle构建工具入门
  18. Objective-c在宏里拼接字符串
  19. 追踪MySQL中长时间运行的事务
  20. vue、入门

热门文章

  1. java 20 -2 递归之找特定目录下的特定格式文件
  2. 委托--delegate
  3. openstack通过salt-cloud创建虚拟机
  4. Open Sans字体兼容问题解决办法[font-face]
  5. 【转】【C#】序列化(Serialize)、反序列化(Deserialize)
  6. 转载:有关SQL server connection Keep Alive 的FAQ(3)
  7. U3D rootMotion
  8. JS原型-语法甘露
  9. Jquery easyui tree的使用
  10. NET中MSMQ的使用----附例子