python字符串
来源:互联网 发布:睡眠工作 知乎 编辑:程序博客网 时间:2024/06/07 00:22
# -*- coding:UTF-8 -*-'''Created on 2015年10月25日@author: young'''from __builtin__ import strs='abc123abc'print s.capitalize() #首字母大写print s.count('ab') #统计字符串出现次数print s.isalpha() #是否仅包含0-9A-Za—zprint s.split('123') #分割print len(s)#字符串长度print s[1] #访问下标为1的字符print s[-1] #倒数第一个print s[-0]print s[1:-1] #第二道倒数第二个print 's[1:1]='+ s[1:1] + 'end'#前闭后开,所以没有字符print s[:-2] #同 s[0:-2]#格式化字符串print 'hello %s , I am %d years old' %('Tom',10) #格式化输出print '%d %x' % (0XFFF,4095)print 'num to str '+str(123)
打印
Abc123abc2False['abc', 'abc']9bcabc123abs[1:1]=endabc123ahello Tom , I am 10 years old4095 fffnum to str 123
0 0
- Python字符串
- Python 字符串
- python字符串
- python 字符串
- 【python】-字符串
- python 字符串
- python字符串
- python 字符串
- python,字符串
- python 字符串
- Python字符串
- Python字符串
- python字符串
- Python 字符串
- python 字符串
- Python 字符串
- Python字符串
- python 字符串
- python文件读写
- 技术笔记
- java IO流的分类和操作
- 常用的9种自动化测试工具
- 兔死狗烹,Twitter对开发者犯下的十宗罪
- python字符串
- iOS开发程序中各种变量的存储位置和程序返回变量的问题
- 一次控制文件参数设置错误导致的restore controlfile 失败。
- SQL Server2008(一)简介
- 练习
- 如何将GPT转MBR分区格式图文教程
- java 算法实现字符串的匹配
- 改善Java文档的理由、建议和技巧
- php try catch