Python论坛  - 讨论区

标题:[python-chinese] 为什么我保存图片文件不是完整的,少一部分

2006年06月20日 星期二 18:00

ly9713 at gmail.com ly9713 at gmail.com
Tue Jun 20 18:00:37 HKT 2006

python-chinese,

为什么我保存图片文件不是完整的,少一部分.数据库中保存的是完整的图片信息.谢谢!

import pymssql
dbstring="select zp_zkz,zp_photo from t_zp"
con = pymssql.connect( host='192.168.1.206', user='', password='', database='zs' )
cur = con.cursor()
#执行SQL语句
cur.execute( str( dbstring ) )

for zpinfo in cur.fetchall():
    print "zkzh is %s" % ( zpinfo[0] )
#    print zpinfo[1]
    
    filename = zpinfo[0] + ".jpg"
    f=open( filename, "wb" )
    f.write(zpinfo[1].read())
    f.close()
con.close()
print "完成!"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060620/4d4d5a87/attachment.html

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

2006年06月20日 星期二 20:42

zhang peng finalmdj at gmail.com
Tue Jun 20 20:42:48 HKT 2006

可能是因为pymssql
最多主能处理字段长度4096吧~
呵呵~ 至少存取text的时候是~
具体有什么解决方法还不知道(除了重新编译pymssql)
在 06-6-20,ly9713 at gmail.com<ly9713 at gmail.com> 写道:
>
> python-chinese,
>
> 为什么我保存图片文件不是完整的,少一部分.数据库中保存的是完整的图片信息.谢谢!
>
> import pymssql
> dbstring="select zp_zkz,zp_photo from t_zp"
> con = pymssql.connect( host='192.168.1.206', user='', password='',
> database='zs' )
> cur = con.cursor()
> #执行SQL语句
> cur.execute( str( dbstring ) )
> for zpinfo in cur.fetchall():
>     print "zkzh is %s" % ( zpinfo[0] )
> #    print zpinfo[1]
>
>     filename = zpinfo[0] + ".jpg"
>     f=open( filename, "wb" )
>     f.write(zpinfo[1].read())
>     f.close()
> con.close()
> print "完成!"
>
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request at lists.python.cn
> Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>
>

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号