Python字符串2
来源:互联网 发布:nginx 限制访问目录 编辑:程序博客网 时间:2024/05/22 18:21
字符串的比较:
1、=
2、startswitch()
3、endswitch()
字符串反转:
1、=
2、startswitch()
3、endswitch()
print'--------------------------'a = 1b = '1'if a == b: print '='else: print '!='print'--------------------------' a= 'hello word'b= 'hello'if(a.startswith(b,0,6)): print 'a==b'else: print 'a!=b' if(a.endswith('word',7,10)): print 'a==b'else: print 'a!=b'输出:--------------------------!=--------------------------a==ba!=b
字符串反转:
def reverse(str): l = list(str) out = '' for i in range(len(l),0,-1): out += ''+l[i-1] return out print reverse('hello')输出:olleh
字符串查找:
正则表达式:
str = '123abc34,djfabf'print str.find('ab',5)print str.find('ab')print str.rfind('ab')print str.replace('ab', 'xx')#print str.replaceFirst('[0-9]{3}',"...")import time,datetimeprint time.strftime('%Y-%m-%d %x %X')t = time.strptime('08/29/16 16:29:30','%x %X') print t import restr = r'^"1"'print re.findall(r'^[a-z]\w*\@[a-z]+\.[com]{3}','s107a880@qq.com')<pre name="code" class="python">输出
12312123xxc34,djfxxf2016-08-29 08/29/16 18:01:56time.struct_time(tm_year=2016, tm_mon=8, tm_mday=29, tm_hour=16, tm_min=29, tm_sec=30, tm_wday=0, tm_yday=242, tm_isdst=-1)['s107a880@qq.com']
0 0
- Python字符串2
- python字符串2
- python学习--2字符串
- python-2 字符串
- python(2) ---字符串函数
- python coobook 2 ---字符串对齐
- python内存管理2-----字符串
- 2-Python字符串和列表
- python处理字符串(2)
- Python字符串
- Python 字符串
- python字符串
- python 字符串
- 【python】-字符串
- python 字符串
- python字符串
- python 字符串
- python,字符串
- 聚合测试数据
- Android 6.0 动态权限机制
- 一种可以避免数据迁移的分库分表scale-out扩容方式
- HTTP请求头域详解
- 什么变量在堆内存里存放,什么变量在栈内存里存放
- Python字符串2
- oracel驱动对中文读取的影响
- AndroidManifest.xml文件结构
- 线性表
- linux 搭建 svn服务器
- [转]如何查看wwwn号
- 简单 --> js+canvas 时钟
- 设计模式中英文对照
- hadoop2.x常用端口