從命令列執行Python 函數
考慮以下Python 程式碼:
<code class="python">def hello(): return 'Hi :)'</code>
考慮以下Python 程式碼:
考慮以下Python 程式碼:
考慮以下Python 程式碼:
<code class="bash">$ python -c 'import foo; print foo.hello()'</code>
考慮下列程式碼指令提供了多個選項。
使用 -c 參數<code class="bash">$ python -c 'from foo import *; print hello()'</code>
簡單命名空間污染
<code class="bash">$ python -c 'from foo import hello; print hello()'</code>
以上是如何從命令列執行Python函數?的詳細內容。更多資訊請關注PHP中文網其他相關文章!