第21届全国大学智能汽车竞赛证书制作
·

01 【获奖证书制作】

一、数据来源
生成证书的所有获奖信息来自于CSDN公布的获奖信息。
- 第21届全国大学生智能车竞赛东北赛区成绩与奖项
- 第21届全国大学生智能车竞赛华北赛区成绩与奖项
- 第21届全国大学生智能车竞赛华东赛区成绩与奖项
- 第21届全国大学生智能车竞赛华南赛区成绩与奖项
- 第21届全国大学生智能车竞赛西部赛区成绩与奖项
- 第21届全国大学生智能车竞赛安徽赛区成绩与奖项
- 第21届全国大学生智能车竞赛山东赛区成绩与奖项
- 第21届全国大学生智能车竞赛浙江赛区成绩与奖项
- 第21届全国大学生智能车竞赛新疆赛区成绩与奖项
二、打印程序
首先使用 csdntmp >aaa 将公布网页中的 Markdown 文本产生 NPZ数据文件。 然后使用一下程序在 “d:\temp\Certification”中产生所有的证书 JPEG 图片文件。
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# CERTPRINT.PY -- by Dr. ZhuoQing 2025-12-25
#
# Note:
#============================================================
from headm import *
#------------------------------------------------------------
templateid = [12, 3, 4, 8, 7] # templatepicture, text, award, order, sn
pictureid = templateid[0]
textid = templateid[1]
awardid = templateid[2]
orderid = templateid[3]
snid = templateid[4]
#------------------------------------------------------------
snhead = 'NCSC2026-06' # NCSCYYYY-area
# 01:DongBei, 02:HuaBei, 03:HuaDong
# 04:HuaNan, 05:XiBu, 06:AnHui, 07:ShanDong
# 08:ZheJiang, 09:XinJiang, 0A:Final
text_width = 46
yearn = 2025
#------------------------------------------------------------
def printjpg(cid, filename):
tspsaveimagerange(cid, filename,0, 50)
# printff(cid, filename)
#------------------------------------------------------------
def getsnstr(typen):
global snhead
randnn1 = random.randint(0, 0x10000)
randnn2 = random.randint(0, 0x10000)
return '%s-%04d-%05d-%05d'%(snhead, typen, randnn1, randnn2)
#------------------------------------------------------------
def boldheitifont(s):
rets = ''
for c in s:
rets = rets + '\\h\\*%s\\.'%c
return rets
def boldfont(s):
rets = ''
for c in s:
rets = rets + '\\*%s\\.'%c
return rets
def settextwidth(s, width):
rets = ''
count = 0
for id,c in enumerate(s):
if c in '\\ . * h'.split():
rets = rets + c
if c == '.':
if count >= width - 1:
count -= (width - 1)
rets += '\r\n'
continue
if ord(c) < 127: count += 1
else: count += 2
appendcount = 0
if s[id:id+4] == yearn:
if count+3 >= width:
rets += '\r\n'
count = 0
rets = rets + c
if count+appendcount >= width:
count -= width
rets += '\r\n'
return rets
#------------------------------------------------------------
def setsntext():
global snid
snstr = getsnstr(1101)
tspsettext(snid, snstr)
def setordertext(os=''):
global orderid
tspsettext(orderid, os)
def setawardtext(aws=""):
global awardid
sn = 13 - (len(aws)+1)//2
# printf(sn)
setstr = ' '*sn + aws
tspsettext(awardid, setstr)
#------------------------------------------------------------
def setteamtext(university, teacher, student, division, group):
global text_width, textid
university = boldheitifont(university)
group = boldfont(group)
setstr = '%s %s 老师,%s 同学,在2026年第二十一届全国大学生智能汽车竞赛中获得 %s %s'%(university,teacher,student,division,group)
setstr = settextwidth(setstr, text_width)
tspsettext(textid, setstr)
#------------------------------------------------------------
def setteachertext(university, teacher, division):
global text_width, textid
university = boldheitifont(university)
setstr = '%s %s老师在2026年第二十一届全国大学生智能汽车竞赛中获得 %s'%(university,teacher, division)
setstr = settextwidth(setstr, text_width)
tspsettext(textid, setstr)
#------------------------------------------------------------
def setuniversitytext(university, division):
global text_width, textid
university = boldheitifont(university)
setstr = '%s 在2026年第二十一届全国大学生智能汽车竞赛中获得 %s'%(university, division)
setstr = settextwidth(setstr, text_width)
tspsettext(textid, setstr)
#------------------------------------------------------------
def setuniteachertext(university, teacher, team, group, division):
global text_width, textid
university = boldheitifont(university)
setstr = '%s %s 同志在2026年第二十一届全国大学生智能汽车竞赛中指导 %s 获得 %s %s 赛题组'%(university, teacher, team, division, group)
setstr = settextwidth(setstr, text_width)
tspsettext(textid, setstr)
#------------------------------------------------------------
def setunistudenttext(university, student, division):
global text_width, textid
university = boldheitifont(university)
setstr = '%s %s 同学在2026年第二十一届全国大学生智能汽车竞赛中获得 %s'%(university, student, division)
setstr = settextwidth(setstr, text_width)
tspsettext(textid, setstr)
#------------------------------------------------------------
if __name__ == "__main__":
# setteamtext("安徽工业大学", "千沐云、李丹", "张子清、方一凡、严峻", "安徽赛区", "缩微电磁")
# setsntext()
# setawardtext("组织贡献奖")
# setordertext()
# printjpg(pictureid, r"d:\temp\1.jpg")
tspboardrefresh()
#--------------------------------------------------------
printf("\a")
#------------------------------------------------------------
# END OF FILE : CERTPRINT.PY
#============================================================
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# PRINTALL.PY -- by Dr. ZhuoQing 2025-12-25
#
# Note:
#============================================================
from headm import *
from CertPrint import *
import shutil
#------------------------------------------------------------
outdir = r'd:\temp\CERTIFICATION'
picdirdef = outdir
if not os.path.isdir(picdirdef):
os.mkdir(picdirdef)
else:
shutil.rmtree(picdirdef)
os.mkdir(picdirdef)
#------------------------------------------------------------
csdnstr, title = tspload('aaa', 'csdnstr', 'title')
strall = str(csdnstr).split("\n")
division = '西部赛区'
#------------------------------------------------------------
for s in strall:
if s.find("#7a37ab") >= 0:
count = 0
if s.find("#008090") >= 0:
count = 0
#--------------------------------------------------------
if s.find("font face") >= 0: continue
if s.find("--|--") >= 0: continue
barcount = s.count('|')
if barcount < 10: continue
#--------------------------------------------------------
count += 1
ss = s.split("|")
univ = ss[1].replace("<br>", "").replace(" ", "")
team = ss[2].replace("<br>", "").replace(" ", "")
group = ss[3].replace("<br>", "").replace(" ", "")
award = ss[4].replace("<br>", "").replace(" ", "")
if award.find(" ") >= 0: continue
if univ.find(" ") >= 0: continue
if team.find(" ") >= 0: continue
if group.find(" ") >= 0: continue
for i in range(2):
t = ss[5+i]
t = t.replace("<br>", "").replace(" ", "")
if t.find(" ") >= 0: continue
if len(t) < 2: continue
printff(count, univ, team, group, award, t)
outfname = "%s_%s_%s_%s.jpg"%(univ, group, team, t)
of = os.path.join(picdirdef, outfname)
setuniteachertext(univ, t, team, group, division)
setsntext()
setawardtext(award)
setordertext("(第%d名)"%count)
tspboardrefresh()
printjpg(pictureid, of)
for i in range(5):
if 7+i >= len(ss): break
t = ss[7+i]
t = t.replace("<br>", "").replace(" ", "")
if t.find("&emsp") >= 0: continue
if len(t) < 2: continue
printff(count, univ, team, group, award, t)
outfname = "%s_%s_%s_%s.jpg"%(univ, group, team, t)
of = os.path.join(picdirdef, outfname)
setunistudenttext(univ, t, division+group)
setsntext()
setawardtext(award)
setordertext("(第%d名)"%count)
tspboardrefresh()
printjpg(pictureid, of)
# break
#------------------------------------------------------------
printf("\a")
exit()
#------------------------------------------------------------
# END OF FILE : PRINTALL.PY
#============================================================

▲ 图1.2.1 示例证书
- 西部赛区证书个数: 1750
- 证书文件: 3.7G
三、生成ZIP文件
将同一所学校的获奖证书压缩到同一个ZIP文件,便于参赛学校下载。
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# ZIPJPEG.PY -- by Dr. ZhuoQing 2026-08-04
#
# Note:
#============================================================
from headm import *
import shutil
import zipfile
#------------------------------------------------------------
jpegdir = r'd:\temp\CERTIFICATION'
outdir = r'd:\temp\CERTIFICATION_ZIP'
picdirdef = outdir
if not os.path.isdir(picdirdef):
os.mkdir(picdirdef)
else:
shutil.rmtree(picdirdef)
os.mkdir(picdirdef)
#------------------------------------------------------------
univdim = []
filedim = os.listdir(jpegdir)
for f in filedim:
ff = f.split("_")
univname = ff[0]
if not univname in univdim:
univdim.append(univname)
#------------------------------------------------------------
for id,u in enumerate(univdim):
outzipfile = os.path.join(picdirdef, '%s.ZIP'%u)
printff(id+1, len(univdim), outzipfile)
fdim = []
for f in filedim:
ff = f.split("_")[0]
if ff == u:
fdim.append(os.path.join(jpegdir,f))
with zipfile.ZipFile(outzipfile, 'w', compression=zipfile.ZIP_DEFLATED) as zf:
for f in fdim:
arc_name = os.path.basename(f)
zf.write(f, arcname=arc_name)
#------------------------------------------------------------
printf("\a")
#------------------------------------------------------------
# END OF FILE : ZIPJPEG.PY
#============================================================
四、获奖证书下载
(1) 清华网盘: https://cloud.tsinghua.edu.cn/d/53f11b59a0904e1db85c/
(2) 百度网盘: 通过网盘分享的文件:
(3) 坚果云盘:https://www.jianguoyun.com/p/DbQPKfIQhcbyCBjEh6YGIAA
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)