python - Azure 表存储 Python SDK,语法无效

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

我正在使用 Azure Table 服务和他们的 python SDK,下面给出的是我的代码的一部分,但我相信错误来自 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 操作系统)中运行时抛出以下错误

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

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

最佳答案

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

来自What's new in Python 3.3 :

To ease the transition from Python 2 for Unicode aware Python applications that make heavy use of Unicode literals, Python 3.3 once again supports the “u” prefix for string literals. This prefix has no semantic significance in Python 3, it is provided solely to reduce the number of purely mechanical changes in migrating to Python 3, making it easier for developers to focus on the more significant semantic changes (such as the stricter default separation of binary and text data).

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

关于python - Azure 表存储 Python SDK,语法无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29457339/

相关文章:

python - Django + Django REST Framework + PostgreSQL查询和序列化非常慢-并非“N + 1”情况

python - 我如何知道哪些 pip 包需要我的 python 项目以及如何列出我已经在我的项目中使用的包

java - 如何在 python 或 java 中将 geotiff 转换为 jpg?

azure - 桥接 Azure Web 应用程序和 Service Fabric

azure - 一个 Cosmos DB 查询中的 TOP 和 DISTINCT

python - 使用基于列表列表中的项目的键创建 Python 字典

python - TensorFlow:卷积网络中的维度不兼容错误

Azure 应用服务无法启动,因为它无法使用 ASP.NET Core 找到 swagger 文档 xml

python - python 3.x 中使用 % 打印的问题

python - 如何避免浮点错误?