SyntaxError: keyword can't be an expression

前端 未结 2 1659
梦谈多话
梦谈多话 2021-01-07 10:04

I have

hd.meta(http-equiv=\'Content-Type\', content=\'text/html;charset=UTF-8\')

And I am getting:

SyntaxError: keyword can\'t be

相关标签:
2条回答
  • 2021-01-07 10:44

    I think http-equiv is being parsed as http minus equiv. You should try http_equiv, or possibly use a special argument depending on the API.

    0 讨论(0)
  • 2021-01-07 10:58

    As @Misandrist already pointed out, http-equiv is interpreted as a subtraction like this: http - equiv.

    If you still need to pass the data to this function, you can do the following thing:

    dct = {
           'http-equiv': 'Content-Type',
           'content': 'text/html;charset=UTF-8'
    }
    hd.meta(**dct)
    

    Put the keyword arguments into a dictionary and pass its expansion (**dct).

    0 讨论(0)
提交回复
热议问题