Python论坛  - 讨论区

标题:[python-chinese] 在idle中能运行,DOS下就不行,太怪了!!!

2006年01月09日 星期一 05:53

冷眼 ibrick at 163.com
Mon Jan 9 05:53:41 HKT 2006

python-chinese,您好!

	哪位牛人来指点指点,程序目的是为了输出一组编码的图像,
在IDLE中运行完成,用python.exe g.py就不行了,太怪了=:<

=================================================================
错误信息:
raceback (most recent call last):
  File "g.py", line 5, in ?
    import Image
  File "C:\Python24\Lib\site-packages\PIL\Image.py", line 68, in ?
    import os, string, sys
  File "D:\Python24\Lib\string.py", line 83, in ?
    import re as _re
  File "D:\Python24\lib\re.py", line 20, in ?
    
AttributeError: 'module' object has no attribute 'search'

*******************************************************************


程序内容:
#--------------------------------------------------------------
# -*- coding: cp936 -*-

from Tkinter import *
from tkFileDialog import *
import Image
import ImageFont
import ImageDraw

outpath = askdirectory ()
font = 'D:/WINDOWS/Fonts/ARIAL.TTF'     # 字体文件路径
list = [(32,2), (14,4), (26,8)]
strls = []
all = 0
accls = {}

for i in list:
	all += 9*i[0]*i[1]
	for l in range(1, i[0] + 1):
		for g in range(1,10):
			n = g*100+l
			for b in range(i[1]):
				strls.append(str(n))
				
if all != len(strls):
	print "len = %d, all = %d" % (len(strls),all)
	print "Error"
	sys.exit(1)

for c in strls:
	if accls.has_key(c):
		accls[c] += 1
	else:
		accls[c] = 1

allstr = accls.keys()
allstr.sort()

endls = []
for ch in allstr:
	endls.append((ch,accls[ch]))
			 

for text in endls:
	im = Image.new("RGB",(260,88),(66,17,17))
	draw = ImageDraw.Draw(im)
	draw.setfont(ImageFont.truetype(font,95))
# Arial = ImageFont.truetype(font,95)

	for i in [0,1,2]:
		draw.text((48+i*55,-11),text[0][i],(255,211,0))
		fname = outpath + '/' + u'哑膜PP背胶-0.06×0.02-%d张-%s.tif' % (text[1],text[0])
		im.save(fname)
# --------------------------- end ------------------------------------

错误信息:
raceback (most recent call last):
  File "g.py", line 5, in ?
    import Image
  File "C:\Python24\Lib\site-packages\PIL\Image.py", line 68, in ?
    import os, string, sys
  File "D:\Python24\Lib\string.py", line 83, in ?
    import re as _re
  File "D:\Python24\lib\re.py", line 20, in ?
    
AttributeError: 'module' object has no attribute 'search'



        致
礼!
 				

        冷眼
        ibrick at 163.com
          2006-01-09

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号