简体   繁体   中英

Python SyntaxError: invalid syntax

My python version is 3.4, below is the error message.

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 ); 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM