字符串 和 模式匹配(python学习手册4)

来源:互联网 发布:三菱q系列plc编程手册 编辑:程序博客网 时间:2024/05/29 12:21

1  字符串在python中具有不可变性--创建后不能改变(例如:不能通过对某一位位置进行赋值而改变字符串)

2  查看字符串相关文档可以利用 help(str)来查看,同理 help(list) , help(dict) , help(set) ,help(tuple) 或者用 dir(tuple)可以查看 内置类支持的操作,help这种方法更为详细一些.

3   s = 'spam'   help(s.replace) 可以查看str下replace的详细用法

4   In [39]: import re
     In [40]: match = re.match('Hello[ \t]*(.*)world', 'Hello Python world')
     In [41]: match.group(1)
     Out[41]: 'Python '









原创粉丝点击