python - 在 Google AppEngine 中将数据导出为 XML 文件

标签 python django google-app-engine

我正在尝试将数据导出到 Google 应用引擎中的 XML 文件,我使用的是 Python/Django。该文件预计包含最多 100K 条转换为 XML 的记录。 App Engine 中是否有等效项:

f = file('blah', 'w+')
f.write('whatever')
f.close()

谢谢

编辑 我想要实现的是将一些信息导出到 XML 文档,以便可以将其导出到 google 位置(不确切知道这将如何工作,但我被告知 google 会不时影响此 xml 文件)时间)。

最佳答案

您还可以使用 Django 模板生成 XML。模板必须包含 HMTL 没有什么特殊原因。我使用这种方法为我的博客生成 Atom feed。模板看起来像这样。我将进入提要的帖子集合传递给它,每个 Post 实体都有一个 to_atom 方法来生成其 Atom 表示形式。

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xml:lang="en"
      xml:base="http://www.example.org">
  <id>urn:uuid:4FC292A4-C69C-4126-A9E5-4C65B6566E05</id>
  <title>Adam Crossland's Blog</title>
  <subtitle>opinions and rants on software and...things</subtitle>
  <updated>{{ updated }}</updated>
  <author>
    <name>Adam Crossland</name>
    <email>adam@adamcrossland.net</email>
  </author>
  <link href="http://blog.adamcrossland.net/" />
  <link rel="self" href="http://blog.adamcrossland.net/home/feed" />
  {% for each_post in posts %}{{ each_post.to_atom|safe }}
  {% endfor %}
</feed>

关于python - 在 Google AppEngine 中将数据导出为 XML 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5104117/

相关文章:

python - 如何访问多对多对象以获得另一个模型属性?

python - 将 'filepath' 列添加到 pandas DataFrame

Python JSON如何过滤返回的数据

django - Django Rest 框架中无效 token 身份验证的自定义响应

django - Django ModelForm验证M2M的自定义自动完成功能,而不是丑陋的Multi-Select

google-app-engine - 免费应用程序中的谷歌云存储空间

java - 升级到 Java8 和端点 V2 后 AppEngine 出现错误

python - 优化应用引擎实体 key 的使用

python - 由于数据库输入错误而切换到特定类别的列

python - 首选 Azure 服务以可扩展的方式使用端点运行 python 脚本