1、返回原点
home()
无参数,直接调用
2、画圆
circle(radius,extent,steps)
参数:radius 指定圆的半径,extent 绘制圆弧的夹角,steps 多边形变数不给默认值
3、画点
dot(size,color)
参数:size绘制点的直径值,color点的色彩
4、印章
stamp()
无参数
5、清除印章
clearstamp(stampid)清楚印章
clearstamps(n=None) 清楚多个印章
参数:stampid是调用stamp函数返回的ID值,n为None则删除全部印章,如果n>0则删除前n个印章,n
利用pyton的PIL,可以很容易的实现印章生成。
但这里细节比较多,例如姓名字数、透明度、噪点、模糊、纹理、旋转角度等等,如果都想齐全了,还得花费一番功夫。
这里记录一下算法的过程,主要过程就是
批量去除指定源文件夹中的py文件的注释,并生成拷贝与指定目的文件夹#!/usr/bin/python
# -*- coding: GBK -*-
#writer:xmnathan
#py文件去注释
import re
import os
import ConfigParser
Python='CleanNote'
def ReadIni(path,section,option):#文件路径,章节,关键词
#读取ini
cf=ConfigParser.ConfigParser()
cf.read(path)
value=cf.get(section,option)#如果用getint()则直接读取该数据类型为整数
return value
def IsPassLine(strLine):
#是否是可以忽略的行
#可忽略行的正则表达式列表
RegularExpressions=["""/'.*#.*/'""","""/".*#.*/"""",
"""/'/'/'.*#.*/'/'/'""","""/"/"/".*#.*/"/"/""""]
for One in RegularExpressions:
zz=re.compile(One)
if re.search(zz,strLine)==None:
continue
else:
return True#有匹配 则忽略
return False
def ReadFile(FileName):
#读取并处理文件
fobj=open(FileName,'r')
AllLines=fobj.readlines()
fobj.close()
NewStr=''
LogStr='/n%20s/n'%(FileName.split('//')[-1])#输出的日志
nline=0
for eachiline in AllLines:
index=eachline.find('#')#获取带注释句‘#’的位置索引
if index==-1 or nline<3 or IsPassLine(eachline):
if eachiline.strip()!='':#排除纯空的行
NewStr=NewStr+eachiline
else:
if index!=0:
NewStr=NewStr+eachiline[:index]+'/n'#截取后面的注释部分
LogStr+="ChangeLine: %s/t%s"%(nline,eachline[index:])
nline+=1
return NewStr,LogStr
def MakeCleanFile(SrcPath,DescPath,FileList):
fLog=open(DescPath+'//'+'CleanNoteLog.txt','w')
for File in FileList:
curStr,LogStr=ReadFile(SrcPath+'//'+File)
fNew=open(DescPath+'//'+File,'w')
fNew=write(curStr)
fNew.close()
fLog.write(LogStr)
fLog.close()
def Main():
#从ini获取源文件夹及目标文件夹路径
IniPath=os.getcwd()+'//'+PtName+'.ini'
SrcPath=ReadIni(IniPath,PyName,'SrcPath')#源文件夹
DescPath=ReadIni(IniPath,PyName,'DescPath')#目的文件夹
#如果目的文件夹不存在,创建之
if not os.path.exists(DescPath):
os.makedirs(DescPath)
FileList=[]
for files in os.walk(SrcPath):
for FileName in files[2]:
if FileName.split('.')[-1]=='py':
FileList.append(FileName)
MakeCleanFile(SrcPath,DescPath,FileList)
if __name__=='__main__':
Main()
print '>>>End<<<'
os.system('pause')
CleanNote.ini的格式
[CleanNote]SrcPath=E:/test
DescPath=E:/test/newfiles