Python 杂感

Python确实比较好用,简洁高效,不用像c,c++这类强定义类型语言那样抠的恨死。

而且有些任务用脚本语言来实现,比动不动就请出c,c++这类火力强悍的工具更省事。

可我总是对python 很迷糊,尤其是对其环境设置有种心虚和恐惧。

一年前用过Python Image Library,使用其中的Pilconvert.py进行图片格式转换,将jpg转换为pgm格式。

当时是在linux平台上做的,做完了没有留下任何使用记录,也许当时觉得没啥好记录的吧。

 

现在在windows下,要实现同样的功能,却搞不定了,脑子迷迷糊糊的,不知道从哪下手,不知道代码该到哪去。

搞不清python 的IDLE,也就是python shell能干些什么。

IDLE在Python doc中解释为 integrated development environment, IDLE offers a Python shell similar to interactive Python interpreter sessions but richer in functionality. It also includes a text editor optimized to edit python source code,  an interactive debugger, and several specialized browsers/viewers.

 

 

我的程序如下,功能是遍历某个目录下的jpg文件,将其转变为pgm格式

from os.path import walk, join, normpath
from os    import chdir, remove
import Image
from os import execv
from PIL import Image
def scan(arg, dirname, names):
    for file in names:
                print file
        if file[-4:]==".jpg":                       
            fname=dirname+file
            print fname
            newname=fname[:-4]+".pgm"
            pilconvert fname newname
if __name__== "__main__":   
    walk("D://data//",scan,0)

总是提示错误,Name error , global name pilconvert is not defined

 

也就是说,没找到pilconvert.py这个文件.

我已经安装了python image library(pil-1.1.7)到C:/Python26/Lib/site-packages/目录下了,pilconvert.py也存在于C:/Python26/Scripts目录下了。另外还拷了一份到当前目录下。

 

为什么还认不到呢?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值