IronPython-如何导入Gzip? [英] IronPython - How do I import Gzip?

查看:91
本文介绍了IronPython-如何导入Gzip?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在VS 2010下使用IronPython.

I am trying to use IronPython under VS 2010.

我需要Gzip,但是没有(我可以找到)文档来告诉我如何引用"或添加模块.

I need Gzip, but there is no (that I can find) documentation to tell me how to "reference" or add a module.

谁能告诉我如何添加Gzip.

Can anyone tell how to add Gzip please.

推荐答案

首先,IronPython不包含gzip模块,因为不支持立即使用.您可以从Python源代码树或 http://提取副本bitbucket.org/jdhardy/ironpythonzlib/src/tip/tests/gzip.py .将此文件放在IronPython安装的Lib文件夹中.

First off, IronPython does not include the gzip module because it's not supported out of the box. You can pull a copy from the Python source tree or from http://bitbucket.org/jdhardy/ironpythonzlib/src/tip/tests/gzip.py. Put this file in the Lib folder of your IronPython installation.

接下来,您需要实现用于IronPython的zlib ;您可能需要.NET 4.0的"clr4"版本.将IronPython.Zlib.dll放入IronPython安装的DLLs文件夹中;如果DLLs文件夹不存在,则只需创建它即可.

Next, you need an implementation of zlib for IronPython; you probably want the 'clr4' version for .NET 4.0. Put IronPython.Zlib.dll in the DLLs folder of your IronPython installation; if the DLLs folder does not exist, just create it.

如果您无法修改IronPython的安装(对于VS 2010,我认为您不能这样做),请将gzip.py和IronPython.Zlib.dll与其余文件放在同一文件夹中,然后添加在其他import语句之后,位于gzip.py顶部附近的以下几行:

If you can't modify the IronPython install (and with VS 2010, I don't think you can), put gzip.py and IronPython.Zlib.dll in the same folder as the rest of your files, and add the following lines near the top of gzip.py, after the other import statements:

if sys.platform == 'cli':
    import clr
    clr.AddReference('IronPython.Zlib')

无论哪种方式,您现在都应该可以从IronPython中执行import gzip.

Either way, you should now be able to do import gzip from IronPython.

这篇关于IronPython-如何导入Gzip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆