易截截图软件、单文件、免安装、纯绿色、仅160KB

python 模块的__name__ __main__

每个模块都有一个名称,在模块中可以通过语句来找出模块的名称。这在一个场合特别有用
——就如前面所提到的,当一个模块被第一次输入的时候,这个模块的主块将被运行。
每个Python模块都有它的__name__,如果它是'__main__',这说明这个模块被用户单独运行,
我们可以进行相应的恰当操作。
#!/usr/bin/python
# Filename: using_name.py
if __name__ == '__main__':
     print 'This program is being run by itself'
else:
     print 'I am being imported from another module'
输出
$ python using_name.py
This program is being run by itself
$ python
>>> import using_name
I am being imported from another module


相关文档:

python 命令行参数


本篇将介绍python中sys, getopt模块处理命令行参数
如果想对python脚本传参数,python中对应的argc, argv(c语言的命令行参数)是什么呢?
需要模块:sys
参数个数:len(sys.argv)
脚本名:    sys.argv[0]
参数1:     sys.argv[1]
参数2:     sys.argv[2]
test.py
1
import ......

Python的bug

Python太火了,不学点都感觉自己不是学计算机的,今天看了个不错的《简明python教程》,很不错。不过在学习过程中,居然发现了一个Python的bug,
#!/usr/bin/python
#coding=UTF-8
class Person:
'''Represents a person.'''
population = 0
def __init__(self, name):
'''Initializes the person's data.'''
......

Python之HTMLParser

"""A parser for HTML and XHTML."""
# This file is based on sgmllib.py, but the API is slightly different.
# XXX There should be a way to distinguish between PCDATA (parsed
# character data -- the normal case), RCDATA (replaceable character
# data -- only char and entity references and end tags a ......

Pamie模块详解 python操作ie浏览器

from http://blog.alexa-pro.cn/?p=315
此文档使用平台为 cPAMIE Build 2.0,和之前的版本有明显的差别,具体可直接看cPAMIE.py 源码
下面是一些常用的方法
ie.navigate('http://blog.alexa.cn') 用来访问一个链接。
ie.linkClick('linkname') 打开这个页面中的一个连接 参数: name或 id
ie.textBoxSet('labels','python ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号