Python论坛  - 讨论区

标题:[python-chinese] 可以使用正则表达式抽取字段吗?

2006年07月11日 星期二 09:51

Cauchy Song cauchy.song at gmail.com
Tue Jul 11 09:51:46 HKT 2006

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

大家好,如下的字符串:

...
125.244.195.194
8080
squid Proxy
KR
2006-7-10
125.244.39.67
8080
squid Proxy
KR
2006-7-10
125.244.54.130
8080
squid Proxy
KR
2006-7-10
...

可以使用python的正则表达式简单的抽取出以下结果吗?
...
(125.244.195.194, 8080, KR)
(125.244.39.67, 8080, KR)
(125.244.54.130, 8080, KR)
...

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (MingW32)

iD8DBQFEswQy90pbDJCgbHoRAviSAJ9HAANCdaH7Sav9pfrSE52FIKwqdwCeOufm
w+NqopXfvPNOQFNZBE5etEo=
=BBQc
-----END PGP SIGNATURE-----


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年07月11日 星期二 12:46

liu zhijie liuzhijie20 at hotmail.com
Tue Jul 11 12:46:48 HKT 2006

我的系统是winxp + sp2
软件:Apache/2.0.58 (Win32) mod_python/3.2.5b Python/2.4.3
在import _apache时,出现以下错误
ImportError: No module named _apache
前面有个兄弟说是软件version的问题
不知道是哪个软件的版本不对啊?
谢谢指导!

_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com  


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年07月11日 星期二 13:10

netkiller openunix at 163.com
Tue Jul 11 13:10:10 HKT 2006

用XML DOM 实现.
----- Original Message ----- 
From: "Cauchy Song" <cauchy.song at gmail.com>
To: <python-chinese at lists.python.cn>
Sent: Tuesday, July 11, 2006 9:51 AM
Subject: [python-chinese] 可以使用正则表达式抽取字段吗?



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

大家好,如下的字符串:

...
125.244.195.194
8080
squid Proxy
KR
2006-7-10
125.244.39.67
8080
squid Proxy
KR
2006-7-10
125.244.54.130
8080
squid Proxy
KR
2006-7-10
...

可以使用python的正则表达式简单的抽取出以下结果吗?
...
(125.244.195.194, 8080, KR)
(125.244.39.67, 8080, KR)
(125.244.54.130, 8080, KR)
...

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (MingW32)

iD8DBQFEswQy90pbDJCgbHoRAviSAJ9HAANCdaH7Sav9pfrSE52FIKwqdwCeOufm
w+NqopXfvPNOQFNZBE5etEo=
=BBQc
-----END PGP SIGNATURE-----

_______________________________________________
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





[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年07月11日 星期二 13:10

gashero harry.python at gmail.com
Tue Jul 11 13:10:56 HKT 2006

大哥,低级错误。
Python中所有以一个下划线开头的东西,包括各种对象,变量,方法,模块等等,都是私有的。你当然不可以引用了。
另外,我测试过3.2.5B和3.2.8有很大的区别,如果你不想升级时很麻烦的话,最好还是抓紧用3.2.8吧。

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年07月11日 星期二 14:21

尹祥龙 yinxianglong at gmail.com
Tue Jul 11 14:21:40 HKT 2006

自己写一个字符串解析函数就ok了。

On 7/11/06, netkiller <openunix at 163.com> wrote:
>
>
> 用XML DOM 实现.
> ----- Original Message -----
> From: "Cauchy Song" <cauchy.song at gmail.com>
> To: <python-chinese at lists.python.cn>
> Sent: Tuesday, July 11, 2006 9:51 AM
> Subject: [python-chinese] 可以使用正则表达式抽取字段吗?
>
>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> 大家好,如下的字符串:
>
> ...
> 125.244.195.194
> 8080
> squid Proxy
> KR
> 2006-7-10
> 125.244.39.67
> 8080
> squid Proxy
> KR
> 2006-7-10
> 125.244.54.130
> 8080
> squid Proxy
> KR
> 2006-7-10
> ...
>
> 可以使用python的正则表达式简单的抽取出以下结果吗?
> ...
> (125.244.195.194, 8080, KR)
> (125.244.39.67, 8080, KR)
> (125.244.54.130, 8080, KR)
> ...
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.4 (MingW32)
>
> iD8DBQFEswQy90pbDJCgbHoRAviSAJ9HAANCdaH7Sav9pfrSE52FIKwqdwCeOufm
> w+NqopXfvPNOQFNZBE5etEo=
> =BBQc
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060711/ce4c42df/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年07月11日 星期二 15:14

Baif.Pogo baif at pogolinux.com.cn
Tue Jul 11 15:14:40 HKT 2006

 
On Tuesday 11 July 2006 13:10, gashero wrote:
> 大哥,低级错误。
> Python中所有以一个下划线开头的东西,包括各种对象,变量,方法,模块等等,都是私有的。你当然不可以引用了。
是么?解释一下?
> 另外,我测试过3.2.5B和3.2.8有很大的区别,如果你不想升级时很麻烦的话,最好还是抓紧用3.2.8吧。

-- 
PogoLinux(Shanghai),Inc. http://www.pogolinux.com.cn (8621)50308860 Ext.31

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年07月11日 星期二 15:23

mouqx xu zsuxqm at gmail.com
Tue Jul 11 15:23:15 HKT 2006

Python对私有变量提供了有限的支持,但Python里并没有真正私有的东西。见文档:
There is limited support for class-private identifiers. Any identifier of
the form __spam (at least two leading underscores, at most one trailing
underscore) is textually replaced with _classname__spam, where classname is
the current class name with leading underscore(s) stripped. This mangling is
done without regard to the syntactic position of the identifier, so it can
be used to define class-private instance and class variables, methods,
variables stored in globals, and even variables stored in instances. private
to this class on instances of *other* classes. Truncation may occur when the
mangled name would be longer than 255 characters. Outside classes, or when
the class name consists of only underscores, no mangling occurs.

On 7/11/06, gashero <harry.python at gmail.com> wrote:
>
> 大哥,低级错误。
> Python中所有以一个下划线开头的东西,包括各种对象,变量,方法,模块等等,都是私有的。你当然不可以引用了。
> 另外,我测试过3.2.5B和3.2.8有很大的区别,如果你不想升级时很麻烦的话,最好还是抓紧用3.2.8吧。
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060711/50aec724/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年07月11日 星期二 21:06

Cauchy Song cauchy.song at gmail.com
Tue Jul 11 21:06:28 HKT 2006

这只是一个简单的例子,未来会更复杂,我想通过配置正则表达式来处理各种情况,而不是为每一种情况都写xml或string解析方法。

在 06-7-11,尹祥龙<yinxianglong at gmail.com> 写道:
> 自己写一个字符串解析函数就ok了。
>
>
>
> On 7/11/06, netkiller <openunix at 163.com> wrote:
> >
> > 用XML DOM 实现.
> > ----- Original Message -----
> > From: "Cauchy Song" < cauchy.song at gmail.com>
> > To: <python-chinese at lists.python.cn>
> > Sent: Tuesday, July 11, 2006 9:51 AM
> > Subject: [python-chinese] 可以使用正则表达式抽取字段吗?
> >
> >
> >
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > 大家好,如下的字符串:
> >
> > ...
> > 125.244.195.194
> > 8080
> > squid Proxy
> > KR
> > 2006-7-10
> > 125.244.39.67
> > 8080
> > squid Proxy
> > KR
> > 2006-7-10
> > 125.244.54.130
> > 8080
> > squid Proxy
> > KR
> > 2006-7-10
> > ...
> >
> > 可以使用python的正则表达式简单的抽取出以下结果吗?
> > ...
> > (125.244.195.194, 8080, KR)
> > ( 125.244.39.67, 8080, KR)
> > (125.244.54.130, 8080, KR)
> > ...
> >
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.4 (MingW32)
> >
> >
> iD8DBQFEswQy90pbDJCgbHoRAviSAJ9HAANCdaH7Sav9pfrSE52FIKwqdwCeOufm
> > w+NqopXfvPNOQFNZBE5etEo=
> > =BBQc
> > -----END PGP SIGNATURE-----
> >
> > _______________________________________________
> > 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
> >
>
>
> _______________________________________________
> 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
>
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年07月11日 星期二 23:04

swordsp sparas2006 at gmail.com
Tue Jul 11 23:04:17 HKT 2006

如果要考虑复杂的情况和未来的变化,用BeautifulSoup之类的专用html解析库(比通用的DOM更方便些)绝对比自己写正则安全省力,代码的可读性和扩展性也要好得多。

On 7/11/06, Cauchy Song <cauchy.song at gmail.com> wrote:
>
> 这只是一个简单的例子,未来会更复杂,我想通过配置正则表达式来处理各种情况,而不是为每一种情况都写xml或string解析方法。
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060711/9b8cf18a/attachment.html

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年07月11日 星期二 23:17

swordsp sparas2006 at gmail.com
Tue Jul 11 23:17:24 HKT 2006

这种写法与其说是语法,不如说更接近"约定"。
模块作者声明这些名字不作为公开的api,模块使用者也应该有意识的避免使用。
必要的时候绕过约定是允许的,但也要付出代价――相比起公开的api,作者是完全不需要保证这些私有成员的稳定性和向后兼容性的。

On 7/11/06, mouqx xu <zsuxqm at gmail.com> wrote:
>
> Python对私有变量提供了有限的支持,但Python里并没有真正私有的东西。见文档:
> There is limited support for class-private identifiers. Any identifier of
> the form __spam (at least two leading underscores, at most one trailing
> underscore) is textually replaced with _classname__spam, where classnameis the current class name with leading underscore(s) stripped. This mangling
> is done without regard to the syntactic position of the identifier, so it
> can be used to define class-private instance and class variables, methods,
> variables stored in globals, and even variables stored in instances. private
> to this class on instances of *other* classes. Truncation may occur when
> the mangled name would be longer than 255 characters. Outside classes, or
> when the class name consists of only underscores, no mangling occurs.
>
> On 7/11/06, gashero <harry.python at gmail.com> wrote:
>
> > 大哥,低级错误。
> Python中所有以一个下划线开头的东西,包括各种对象,变量,方法,模块等等,都是私有的。你当然不可以引用了。
> 另外,我测试过3.2.5B和3.2.8有很大的区别,如果你不想升级时很麻烦的话,最好还是抓紧用3.2.8吧。
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060711/3348842e/attachment.htm

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年07月12日 星期三 09:06

netkiller openunix at 163.com
Wed Jul 12 09:06:21 HKT 2006

r'^[a-z]+$'


----- Original Message ----- 
From: "Cauchy Song" <cauchy.song at gmail.com>
To: <python-chinese at lists.python.cn>
Sent: Tuesday, July 11, 2006 9:06 PM
Subject: Re: [python-chinese] 可以使用正则表达式抽取字段吗?


> 这只是一个简单的例子,未来会更复杂,我想通过配置正则表达式来处理各种情况,而不是为每一种情况都写xml或string解析方法。
>
> 在 06-7-11,尹祥龙<yinxianglong at gmail.com> 写道:
>> 自己写一个字符串解析函数就ok了。
>>
>>
>>
>> On 7/11/06, netkiller <openunix at 163.com> wrote:
>> >
>> > 用XML DOM 实现.
>> > ----- Original Message -----
>> > From: "Cauchy Song" < cauchy.song at gmail.com>
>> > To: <python-chinese at lists.python.cn>
>> > Sent: Tuesday, July 11, 2006 9:51 AM
>> > Subject: [python-chinese] 可以使用正则表达式抽取字段吗?
>> >
>> >
>> >
>> > -----BEGIN PGP SIGNED MESSAGE-----
>> > Hash: SHA1
>> >
>> > 大家好,如下的字符串:
>> >
>> > ...
>> > 125.244.195.194
>> > 8080
>> > squid Proxy
>> > KR
>> > 2006-7-10
>> > 125.244.39.67
>> > 8080
>> > squid Proxy
>> > KR
>> > 2006-7-10
>> > 125.244.54.130
>> > 8080
>> > squid Proxy
>> > KR
>> > 2006-7-10
>> > ...
>> >
>> > 可以使用python的正则表达式简单的抽取出以下结果吗?
>> > ...
>> > (125.244.195.194, 8080, KR)
>> > ( 125.244.39.67, 8080, KR)
>> > (125.244.54.130, 8080, KR)
>> > ...
>> >
>> > -----BEGIN PGP SIGNATURE-----
>> > Version: GnuPG v1.4.4 (MingW32)
>> >
>> >
>> iD8DBQFEswQy90pbDJCgbHoRAviSAJ9HAANCdaH7Sav9pfrSE52FIKwqdwCeOufm
>> > w+NqopXfvPNOQFNZBE5etEo=
>> > =BBQc
>> > -----END PGP SIGNATURE-----
>> >
>> > _______________________________________________
>> > 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
>> >
>>
>>
>> _______________________________________________
>> 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 




[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号