我正在使用 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 时.
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/