【问题标题】:Azure Table Storage Python SDK, Invalid syntaxAzure 表存储 Python SDK,语法无效
【发布时间】:2015-06-10 00:40:37
【问题描述】:

我正在使用他们的 python SDK 使用 Azure Table 服务,下面给出的是我的代码的一部分,但我相信错误来自 SDK 内部

from azure.storage import TableService, Entity
from datetime import datetime

ac_name = 'my_account_name'
primary_key = 'my_primary_key'
table_name = 'my_table_name'

def get_connection_string_and_create_table():
    global table_service
    table_service = TableService(account_name = ac_name,account_key=primary_key)
    table_service.create_table(table=table_name)

代码在 Windows 中运行时运行良好,但在尝试在 Raspberry(运行 Raspbian OS)中运行时抛出以下错误

from azure.storage import TableService, Entity
File "/usr/local/lib/python3.2/dist-packages/azure/storage/__init__.py" line 55
self.prefix = u''

SyntaxError: invalid syntax

有人可以帮我解决这个问题吗? :) 我会非常高兴:)

【问题讨论】:

    标签: python azure python-3.x raspberry-pi azure-table-storage


    【解决方案1】:

    only in Python 3.3 重新引入了用于字符串文字的 u"" 语法,因此您使用的是 Python 3.2 you will get a syntax error

    来自What's new in Python 3.3

    为了简化从 Python 2 到 Unicode 感知 Python 的过渡 大量使用 Unicode 文字的应用程序,Python 3.3 一次 再次支持字符串文字的 “u” 前缀。这个前缀没有 Python 3 中的语义意义,提供它只是为了减少 迁移到 Python 3 的纯机械变化的数量,使得 开发人员更容易专注于更重要的语义 更改(例如更严格的二进制和文本的默认分隔 数据)。

    所以,要么去掉u''(默认情况下,Python 3 中的所有字符串都已经是 unicode 字符串),要么将 Python 3 升级到更新版本以使其工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-23
      • 2019-09-22
      • 2014-10-18
      相关资源
      最近更新 更多