python语法-self.\u设置的含义
我是python新手,试图理解以下基本python语法。提前谢谢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
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