一套python文本工具
py-text的Python项目详细描述
一套python文本工具
安装
最新的稳定版本是py-text-1.2.tar.gz
python setup.py install
开始
py文本的awk演示:
fromtextimportawkdata=['root:x:0:0:root:/root:/bin/bash','daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin','bin:x:2:2:bin:/bin:/usr/sbin/nologin']resut=awk.awk(data,None,':',[0,4,5])printresult[['root','root','/root'],['daemon','daemon','/usr/sbin'],['bin','bin','/bin']]
py文本的字符串实用程序演示:
fromtextimportstring_utilprint'substring_before : '+string_utils.substring_before('one world one dream','one dream').strip()+'\n'print'abbreviate : '+string_utils.abbreviate('abcdef',3,3)+'\n'print'count_matches : '+string_utils.count_matches('one world one dream','one')+'\n'substring_before:oneworldabbreviate:abc***count_matches:2
py文本的regex实用程序演示:
fromtextimportregex_utilprint'check_line : '+regex_utils.check_line('.*(\d+.\d+.\d+.\d+)','MyIP is 192.168.199.4')+'\n'print'parse_line : '+str(regex_utils.parse_line('name=(\S+), type=(\S+)','name=ASA5505, type=Firewall)) + '\n'check_line:Trueparse_line:['ASA5505','Firewall']
文档
完整文档位于[此处]()。 资源位于docs/目录中。
许可证
py文本是根据apache许可证2.0版授权的。有关完整的许可文本,请参见许可证