1. 程式人生 > >PyCharm 設定執行引數

PyCharm 設定執行引數

def square(x):
    '''
    square a number and returns the result
    >>> square(2)
    4
    >>> square(3)
    9
    '''
    return x**2

if __name__ == '__main__':
    import doctest, test
    doctest.testmod(test)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

對於如下的一段用作單元測試的 .py 檔案而言,直接在 PyCharm 中執行(ctrl + shift + F10)是沒有任何輸出的,在命令列介面

C:\Users\Administrator\PycharmProjects\test> python test.py
  • 1

也是沒有輸出的,增加一個執行引數:-v(表示 verbose,詳細資訊):

C:\Users\Administrator\PycharmProjects\test> python test.py -v
  • 1

便會輸出相關的測試資訊。

那麼我們又該如何在 PyCharm 中設定相關的執行引數?

【Run】⇒ 【Edit Configurations】⇒ 【Script parameters】 ⇒ -v

即可執行,在控制檯輸出相關的除錯資訊了。

 


這裡寫圖片描述

 

再分享一下我老師大神的人工智慧教程吧。零基礎!通俗易懂!風趣幽默!還帶黃段子!希望你也加入到我們人工智慧的隊伍中來!https://www.cnblogs.com/captainbed