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

PEP 0263 Defining Python Source Code Encodings

 
PEP 0263
Defining Python Source Code Encodings
Python will default to ASCII as standard encoding if no other
encoding hints are given.
To define a source code encoding, a magic comment must
be placed into the source files either as first or second
line in the file, such as:
# coding=<encoding name>
or (using formats recognized by popular editors)
#!/usr/bin/python
# -*- coding: <encoding name> -*-
or
#!/usr/bin/python
# vim: set fileencoding=<encoding name> :
More precisely, the first or second line must match the regular
expression "coding[:=]\s*([-\w.]+)". The first group of this
expression is then interpreted as encoding name.
To aid with platforms such as Windows, which add Unicode BOM
marks to the beginning of Unicode files, the UTF-8 signature
'\xef\xbb\xbf' will be interpreted as 'utf-8' encoding as well
(even if no magic encoding comment is given).
但是在eclipse Pydev中指定源代码文件为utf-8格式,eclipse不会添加BOM(或其他原因),所以
要在第一行或者第二行添加匹配"coding[:=]\s*([-\w.]+)"的字符串


相关文档:

删除工程中svn文件的脚本(Ruby版和Python版)

两种不同的语言,不同的表达!
Python脚本实现.
""
"
    File Name : clean.py
    File Date : 2009/11/5 14:22:56
    Author     : DannyLai
    Purpose     : Cle ......

Python装饰器

原文:http://www.klipdas.com/blog/?p=python-decorator
python装饰器介绍
Python 2.2中引入的 classmethod() 和 staticmethod() 内置函数,你可以这样调用classmethod():
class A:
def foo(self, y):
print y
foo = classmethod(foo)
也可以这样:
class A:
@classmethod
def foo(sel ......

穿越Python Challenge(0

一个有趣的网站:
http://www.pythonchallenge.com/
集娱乐与学习于一体,在开动脑筋闯关的过程中,不但扩展了思维,还对Python加深了理解。
一共33关,每闯过一关都可以在提示下查看作者给出的Solution。
第0关(指导关):
    出现一幅画面,上面写着2**38,教你如何进入下一关。  
&nb ......

Python 线程操作

在python中如何创建一个线程对象
如果你要创建一个线程对象,很简单,只要你的类继承threading.Thread,然后在__init__里首先调用threading.Thread的__init__方法即可
import threading
class mythread(threading.Thread):
    def __init__(self, threadname):
      & ......

python中文件和目录操作

1.获得当前路径
在Python中可以使用os.getcwd()函数获得当前的路径。其原型如下所示。
os.getcwd()
该函数不需要传递参数,它返回当前的目录。需要说明的是,当前目录并不是指脚本所在的目录,而是所运行脚本的目录。例如,在PythonWin中输入如下脚本。
>>> import os
>>> print 'current director ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号