Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Dict关键字can';这不是一种表达。如何将变量从对象转换为整数_Python_Python 3.x_Dictionary - Fatal编程技术网

Python Dict关键字can';这不是一种表达。如何将变量从对象转换为整数

Python Dict关键字can';这不是一种表达。如何将变量从对象转换为整数,python,python-3.x,dictionary,Python,Python 3.x,Dictionary,我想把一个变量从object转换成integer mapper = dict('А Б' = 0 , 'Г Д' = 1) SyntaxError: keyword can't be an expression ‘АБ’、‘ГБ’-俄语字母。 将变量从对象转换为整数的正确方法是什么? python 3.5或2.7都只需使用dict文本: mapper = {'А Б': 0, 'Г Д': 1} 这个错误是绝对正确的。不能单独执行'foo'=4,也不能在函数调用中执行

我想把一个变量从object转换成integer

mapper = dict('А Б' = 0 , 'Г Д' = 1)
SyntaxError: keyword can't be an expression
‘АБ’、‘ГБ’-俄语字母。 将变量从对象转换为整数的正确方法是什么?
python 3.5或2.7都只需使用dict文本:

mapper = {'А Б': 0, 'Г Д': 1}
这个错误是绝对正确的。不能单独执行
'foo'=4
,也不能在函数调用中执行