Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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语法-self.\u设置的含义_Python - Fatal编程技术网

python语法-self.\u设置的含义

python语法-self.\u设置的含义,python,Python,我是python新手,试图理解以下基本python语法。提前谢谢 foo = self._setup['bar'] 更新:修复了我前面代码段中的打字错误。这不是有效的Python,因为Python不是关键字: >>> foo = python self._setup['bar'] File "<stdin>", line 1 foo = python self._setup['bar'] ^ SyntaxErro

我是python新手,试图理解以下基本python语法。提前谢谢

foo = self._setup['bar']

更新:修复了我前面代码段中的打字错误。

这不是有效的Python,因为
Python
不是关键字:

>>> foo = python self._setup['bar']
  File "<stdin>", line 1
    foo = python self._setup['bar']
                    ^
SyntaxError: invalid syntax
其结构如下:

self                     # Get the value of self (typically the current object)
self._setup              # Get the attribute "_setup" of that value
self._setup['bar']       # Get the item "bar" of the attribute value
foo = self._setup['bar'] # Assign the result to the variable foo

这些都是非常基本的结构。有关详细信息,请参阅。

这不是有效的Python,因为
Python
不是关键字:

>>> foo = python self._setup['bar']
  File "<stdin>", line 1
    foo = python self._setup['bar']
                    ^
SyntaxError: invalid syntax
其结构如下:

self                     # Get the value of self (typically the current object)
self._setup              # Get the attribute "_setup" of that value
self._setup['bar']       # Get the item "bar" of the attribute value
foo = self._setup['bar'] # Assign the result to the variable foo

这些都是非常基本的结构。有关详细信息,请参阅。

Argh-修复了我问题中的打字错误。谢谢@phihagArgh-修复了我问题中的拼写错误。谢谢@phihag