2006年05月01日 星期一 23:56
第 9 行缩进不对 第 10 行改成: li.search(str).groups() biosedit at gmail.com 写道: > |#!/usr/bin/python > 3 |# This Python file uses the following encoding: utf-8 > 4 |import re > 5 |pattern='^[^1]' > 6 |f=open('/var/log/apache2/access.log','r') > 7 |readlines=f.readlines() > 8 |for str in readlines: > 9 | li =re.compile(pattern) > 10 | li.search(pattern).groups() > 11 |f.close() > | > File "./http.py", line 9 > li.search(pattern).groups() > ^ > IndentationError: unindent does not match any outer indentation level > http://www.woodpecker.org.cn/obp/diveintopython-zh-5.4/zh-cn/dist/html/toc/index.html > > groups()该怎么用
2006年05月02日 星期二 14:39
|#!/usr/bin/python 3 |# This Python file uses the following encoding: utf-8 4 |import re 5 |list=[] 6 |pattern='^[^1]' 7 |f=open('/var/log/apache2/access.log','r') 8 |readlines=f.readlines() 9 |for str in readlines: 10 | li =re.compile(pattern) 11 | print li.search('/var/log/apache2/access.log').groups() 12 |f.close() | 返回的是1000多个() 在 06-5-1,tocer<tocer.deng at gmail.com> 写道: > 第 9 行缩进不对 > 第 10 行改成: > li.search(str).groups() > > biosedit at gmail.com 写道: > > |#!/usr/bin/python > > 3 |# This Python file uses the following encoding: utf-8 > > 4 |import re > > 5 |pattern='^[^1]' > > 6 |f=open('/var/log/apache2/access.log','r') > > 7 |readlines=f.readlines() > > 8 |for str in readlines: > > 9 | li =re.compile(pattern) > > 10 | li.search(pattern).groups() > > 11 |f.close() > > | > > File "./http.py", line 9 > > li.search(pattern).groups() > > ^ > > IndentationError: unindent does not match any outer indentation level > > > http://www.woodpecker.org.cn/obp/diveintopython-zh-5.4/zh-cn/dist/html/toc/index.html > > > > groups()该怎么用 > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese >
2006年05月02日 星期二 15:16
你想要什么结果?具体说说。 biosedit at gmail.com 写道: > |#!/usr/bin/python > 3 |# This Python file uses the following encoding: utf-8 > 4 |import re > 5 |list=[] > 6 |pattern='^[^1]' > 7 |f=open('/var/log/apache2/access.log','r') > 8 |readlines=f.readlines() > 9 |for str in readlines: > 10 | li =re.compile(pattern) > 11 | print li.search('/var/log/apache2/access.log').groups() > 12 |f.close() > | > 返回的是1000多个()
2006年05月02日 星期二 16:18
删除与^1[2,9]匹配的行,打印余下的行 在 06-5-2,tocer<tocer.deng at gmail.com> 写道: > 你想要什么结果?具体说说。 > > biosedit at gmail.com 写道: > > |#!/usr/bin/python > > 3 |# This Python file uses the following encoding: utf-8 > > 4 |import re > > 5 |list=[] > > 6 |pattern='^[^1]' > > 7 |f=open('/var/log/apache2/access.log','r') > > 8 |readlines=f.readlines() > > 9 |for str in readlines: > > 10 | li =re.compile(pattern) > > 11 | print li.search('/var/log/apache2/access.log').groups() > > 12 |f.close() > > | > > 返回的是1000多个() > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese >
2006年05月02日 星期二 16:29
#!/usr/bin/python # This Python file uses the following encoding: utf-8 import re pattern='^1[2,9]' li =re.compile(pattern) f=open('/var/log/apache2/access.log','r') for str in f.readlines(): if not li.match(str): print str f.close() biosedit at gmail.com 写道: > 删除与^1[2,9]匹配的行,打印余下的行 > > 在 06-5-2,tocer<tocer.deng at gmail.com> 写道: >> 你想要什么结果?具体说说。
2006年05月02日 星期二 18:24
非常感谢前辈回帖,我会慢慢看这些函数的 在 06-5-2,tocer<tocer.deng at gmail.com> 写道: > #!/usr/bin/python > # This Python file uses the following encoding: utf-8 > > import re > pattern='^1[2,9]' > li =re.compile(pattern) > f=open('/var/log/apache2/access.log','r') > for str in f.readlines(): > if not li.match(str): print str > f.close() > > > biosedit at gmail.com 写道: > > 删除与^1[2,9]匹配的行,打印余下的行 > > > > 在 06-5-2,tocer<tocer.deng at gmail.com> 写道: > >> 你想要什么结果?具体说说。 > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese >
2006年05月02日 星期二 18:29
不客气。 5.1了,好好休息吧:) biosedit at gmail.com 写道: > 非常感谢前辈回帖,我会慢慢看这些函数的 > > 在 06-5-2,tocer<tocer.deng at gmail.com> 写道: >> #!/usr/bin/python >> # This Python file uses the following encoding: utf-8 >> >> import re >> pattern='^1[2,9]' >> li =re.compile(pattern) >> f=open('/var/log/apache2/access.log','r') >> for str in f.readlines(): >> if not li.match(str): print str >> f.close() >> >> >> biosedit at gmail.com 写道: >> > 删除与^1[2,9]匹配的行,打印余下的行 >> > >> > 在 06-5-2,tocer<tocer.deng at gmail.com> 写道: >> >> 你想要什么结果?具体说说。 >> _______________________________________________ >> python-chinese >> Post: send python-chinese at lists.python.cn >> Subscribe: send subscribe to python-chinese-request at lists.python.cn >> Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn >> Detail Info: http://python.cn/mailman/listinfo/python-chinese >> > > ------------------------------------------------------------------------ > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese
Zeuux © 2025
京ICP备05028076号