<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # Python `locals()`函數 > 原文: [https://thepythonguru.com/python-builtin-functions/locals/](https://thepythonguru.com/python-builtin-functions/locals/) * * * 于 2020 年 1 月 7 日更新 * * * `locals()`函數返回一個字典,其中包含在本地名稱空間中定義的變量。 在全局名稱空間中調用`locals()`與調用[`globals()`](/python-builtin-functions/globals/)相同,并返回代表模塊全局名稱空間的字典。 其語法如下: ```py locals() -> dictionary containg local scope variables ``` 這是一個例子: ```py #!/usr/bin/python3 from pprint import pprint a = 10 b = 20 def foo(): x = 30 # x and y are local variables y = 40 print("locals() = {0}".format(locals())) pprint(locals()) # same as calling globals() print('*' * 80) print("locals() == globals()? ", locals() == globals()) print('*' * 80) foo() ``` **預期輸出**: ```py {'__builtins__': <module 'builtins' (built-in)>, '__cached__': None, '__doc__': None, '__file__': 'module1.py', '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x7fa18790a828>, '__name__': '__main__', '__package__': None, '__spec__': None, 'a': 10, 'b': 20, 'foo': <function foo at 0x7fa1878752f0>, 'pprint': <function pprint at 0x7fa1878756a8>} ******************************************************************************** locals() == globals()? True ******************************************************************************** locals() = {'y': 40, 'x': 30} ``` 試試看: ```py from pprint import pprint a = 10 b = 20 def foo(): x = 30 # x and y are local variables y = 40 print("locals() = {0}".format(locals())) pprint(locals()) # same as calling globals() print('*' * 80) print("locals() == globals()? ", locals() == globals()) print('*' * 80) foo() ``` * * * * * *
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看