我每次上传的文件读到的数据都不正确。2M 的图片读得10多K 。。哪位大侠可以帮帮我啊。
#!D:\ProgrammerTools\python26\python.exe
#encoding=utf-8
import cgitb
import os
cgitb.enable()
import cgi,urllib, md5
print "Content-type: text/html"
print""
print """<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>asdsadas</title></head><body>"""
form = cgi.FieldStorage()
if form.has_key('file'):
fileitem = form['file']
if not fileitem.file:
print "Error: not a file upload.<P>"
else:
datas=[]
while True:
data = fileitem.file.read(1024)
if not data:
break
datas.append(data)
for d in datas:
file(cgi.escape(fileitem.filename).decode("utf-8"),'wb').write(d)
else:
相关问答:
python如何解压缩.Z的文件啊,在windows系统环境下
Q7Z 是一款基于 Qt4 的 7z 压缩工具
http://code.google.com/p/k7z/
开源的
http://sourceforge.net/projects/k7z/
LS的能具体说一说吗?
......
我用了def CreateMyDialog(self):
dlg = MyDialog(None, -1, ''.decode('utf8'), (300,300), (300,200), wx.DEFAULT_DIALOG_STYLE | wx.DIALOG_NO_PARENT )
&nbs ......
各位高手,哪位能写个简单的通讯录,只保存姓名和手机号,能保存到硬盘并可读回,有添加,删除,修改,查询功能,命令行式的就行
这种活你得自己干,有问题可以问,但不会有人帮你做的。
给你源码
http://dow ......
python "$cur_path/script/upgrade.py" "$@"
你看看upgrade.py的内容就知道了
传给 upgrade 的命令行参数
把"$@"给 "$cur_path/script/upgrade.py" 处理。
......
如题,
《python源码剖析》中第32页,
有个检查加法结果是否溢出的代码,
大致如下:
C/C++ code:
long a, b, x;
x = a + b;
//检查结果是否溢出
if((x^a)>=0 || (x^b)>=0)
return OK; // ......