语法错误:关键字不能是表达式 [英] SyntaxError: keyword can't be an expression

查看:59
本文介绍了语法错误:关键字不能是表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有

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

我得到:

语法错误:关键字不能是表达式

SyntaxError: keyword can't be an expression

为什么会这样?

推荐答案

正如@Misandrist 已经指出的,http-equiv 被解释为这样的减法:http - equiv.

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)

将关键字参数放入字典并传递其扩展(**dct).

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

这篇关于语法错误:关键字不能是表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆