我在Windows 7(64位)上使用Python 2.7.当我尝试用ZipFile模块解压缩zip文件时,我收到以下错误: -
Traceback (most recent call last):
File "unzip.py", line 8, in <module>
z.extract(name)
File "C:\Python27\lib\zipfile.py", line 950, in extract
return self._extract_member(member, path, pwd)
File "C:\Python27\lib\zipfile.py", line 993, in _extract_member
source = self.open(member, pwd=pwd)
File "C:\Python27\lib\zipfile.py", line 897, in open
raise BadZipfile, "Bad magic number for file header"
zipfile.BadZipfile: Bad magic number for file header
Run Code Online (Sandbox Code Playgroud)
WinRAR可以提取我试图提取的文件.这是我用来从中提取文件的代码myzip.zip
from zipfile import ZipFile
z = ZipFile('myzip.zip') //myzip.zip contains just one file, a password protected pdf
for name in z.namelist():
z.extract(name) …
Run Code Online (Sandbox Code Playgroud) 我在Windows 7(64位)上使用Python 2.5.
我安装了pycurl-7.15.5.1(带有win二进制文件)和龙卷风(使用pip).
当我运行以下hello world代码时:
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello World!")
if __name__=='__main__':
app = tornado.web.Application([(r"/",MainHandler),])
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Run Code Online (Sandbox Code Playgroud)
我收到以下错误: -
Traceback (most recent call last):
File "hello_tornado.py", line 11, in <module>
application.listen(8888)
File "c:\Python25\Lib\site-packages\tornado\web.py", line 1193, in listen
server.listen(port, address)
File "c:\Python25\Lib\site-packages\tornado\netutil.py", line 100, in listen
sockets = bind_sockets(port, address=address)
File "c:\Python25\Lib\site-packages\tornado\netutil.py", line 263, in bind_sockets
sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
AttributeError: 'module' object has no attribute 'IPV6_V6ONLY'
Run Code Online (Sandbox Code Playgroud) 我运行的CherryPy 3.2.0服务器与Python 2.5.1,它提供了以下错误每隔几天从UI任何指令,直至被杀害,并且重新开始: -
[29/Mar/2012:06:37:57] HTTP Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0-py2.5.egg/cherrypy/_cprequest.py", line 636, in respond
File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0-py2.5.egg/cherrypy/_cprequest.py", line 97, in run
File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0-py2.5.egg/cherrypy/_cprequest.py", line 57, in __call__
File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0-py2.5.egg/cherrypy/lib/sessions.py", line 757, in init
File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0-py2.5.egg/cherrypy/lib/sessions.py", line 162, in __init__
File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0-py2.5.egg/cherrypy/lib/sessions.py", line 190, in _regenerate
File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0-py2.5.egg/cherrypy/lib/sessions.py", line 204, in generate_id
File "/usr/lib/python2.5/site-packages/CherryPy-3.2.0-py2.5.egg/cherrypy/_cpcompat.py", line 264, in random20
File "/usr/lib/python2.5/os.py", line 733, in urandom
NotImplementedError: /dev/urandom (or equivalent) not found
Run Code Online (Sandbox Code Playgroud)
_cpcompat.py
有一段代码表明,random.random
如果cherrypy无法读取/dev/urandom
,但似乎没有倒退,则会出现回落.
try:
os.urandom(20)
import …
Run Code Online (Sandbox Code Playgroud) 我的Windows 7机器上有Python 2.5.x.
os.path.exists('C:') # returns True
os.path.exists('C:\Users') # returns True
os.path.exists('C:\Users\alpha') # returns False, when ALPHA is a user on my machine
Run Code Online (Sandbox Code Playgroud)
我给了我正在使用的CLI的读/写权限.可能的原因是什么?
我想禁用基于Web的访问我的应用程序给我或任何人.我有一些cron工作正在运行.这就是我想要的.
我写了一个示例代码,用于从Python中的谷歌应用引擎发送电子邮件.我无法弄清楚为什么每次发送两次邮件?
mail.py: -
from google.appengine.api import mail
mail.send_mail(sender="ALPHA <ALPHA@gmail.com>",
to="BETA <BETA@hotmail.com>",
subject="test mail",
body="""
Dear BETA,
How have you been?
Regards,
ALPHA
""")
Run Code Online (Sandbox Code Playgroud)
app.yaml: -
application: MyUniqueAppID
version: 1
runtime: python
api_version: 1
handlers:
- url: .*
script: mail.py
Run Code Online (Sandbox Code Playgroud)