易截截图软件、单文件、免安装、纯绿色、仅160KB

IIS 7 python 2.6 cgi 文件上传问题

我每次上传的文件读到的数据都不正确。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 异常退出

最近用python写一个程序,总是异常退出,但是却没法用try..except来捕捉

由于没法发图片,所以把相关的信息打印出来
异常的信息大致如下:

python.exe遇到问题需要关闭。我们对此引起的不便表示抱歉 ......

python的引用计数

我用了def CreateMyDialog(self):
        dlg = MyDialog(None, -1, ''.decode('utf8'), (300,300), (300,200), wx.DEFAULT_DIALOG_STYLE | wx.DIALOG_NO_PARENT )
&nbs ......

谁用过python 的mock 做unit test

如果一段代码

Python code:

#!/usr/bin/python2.5
from urllib2 import Request,urlopen,URLError
def check():
req = Request('http://www.google.com')
try:
res = urlopen(req).read()
......

Windows下用Python你会几种copy文件的方法?

1. os.system
Python code:
import os
import tempfile
filename1 = tempfile.mktemp (".txt")
open (filename1, "w").close ()
filename2 = filename1 + ".copy"
print fi ......

《python源码剖析》,检查加法结果是否溢出?

如题,
《python源码剖析》中第32页,
有个检查加法结果是否溢出的代码,
大致如下:
C/C++ code:
long a, b, x;
x = a + b;
//检查结果是否溢出
if((x^a)>=0 || (x^b)>=0)
return OK; // ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号