Google App Engine,如何制作本地文件对象? [英] Google App Engine, How to make native file object?

查看:106
本文介绍了Google App Engine,如何制作本地文件对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将从urlfetch获得的一些数据转换为本地python文件对象。
有谁知道如何做到这一点?

I'm trying to convert some data got from urlfetch to native python file object. Does anyone know how to do this?

我了解GAE无法将文件保存到本地。
但由于库的规范,我需要文件对象。

I understand GAE can't save files to local. But I need file object due to library's specification.

推荐答案

您可以使用python的 StringIO 类,以围绕由URL提取检索的任何数据包装类似文件的对象。

You can use python's StringIO class to wrap a a file-like object around any data retrieved by URL Fetch.

如果您使用python的 urllib2.urlopen()而不是谷歌的网址提取API,你会得到一个类似文件的对象,这可能与你的图书馆工作。

If you use python's urllib2.urlopen() instead of Google's URL Fetch API, you'll get a file-like object which might work with your library.

这篇关于Google App Engine,如何制作本地文件对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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