[英]Python SyntaxError: invalid syntax
My python version is 3.4, below is the error message. 我的python版本是3.4,下面是错误消息。
Traceback (most recent call last):
File "test.py", line 1, in <module
from avs_client import AlexaVoiceServiceClient
File "/home/mstts/Documents/Amazon/alexa-voice-service-client/avs_client/__init__.py", line 1, in <module
from avs_client.avs_client.client import AlexaVoiceServiceClient
File "/home/mstts/Documents/Amazon/alexa-voice-service-client/avs_client/avs_client/client.py", line 5, in <module
from avs_client.avs_client import authentication, connection, device, ping
File "/home/mstts/Documents/Amazon/alexa-voice-service-client/avs_client/avs_client/connection.py", line 64
**authentication_headers,
^
SyntaxError: invalid syntax
And below is code segment which raises the error. 下面是引发错误的代码段。
headers = {
**authentication_headers,
'Content-Type': multipart_data.content_type
}
Thanks for anyone who could be as kind to let me know what I am doing wrong and why that would be great! 感谢任何愿意让我知道我在做错事情的人,以及为什么这样做很棒!
This additional unpacking syntax for dictionary literals was introduced in Python 3.5 (see PEP-448 ); 在Python 3.5中引入了字典文字的这种额外的解包语法(请参阅PEP-448 ); in earlier versions, it's a syntax error.
在早期版本中,这是语法错误。 If you cannot upgrade, you will have to create the headers in two steps, eg:
如果无法升级,则必须分两个步骤创建标题,例如:
headers = {'Content-Type': multipart_data.content_type}
headers.update(**authentication_headers)
as suggested by Ozgur in the comments . 如Ozgur 在评论中所建议。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.