你能列出函數接收的關鍵字參數嗎?

| | |

我有一個字典,我需要將鍵/值作為關鍵字參數傳遞。例如..

d_args = {"kw1": "value1", "kw2": "value2"} example(**d_args) 

這很好用,但是如果 d_args dict 中有不被 接受的值example 函數,它顯然死了。說,如果示例函數定義為 def example(kw2):

這是一個問題,因為我沒有"t控制 d_argsexample 函數的生成。它們都來自外部模塊,example 只接受一些關鍵字- 來自字典的參數..

理想情況下我會這樣做

parsed_kwargs = feedparser.parse(the_url) valid_kwargs = get_valid_kwargs(parsed_kwargs, valid_for = PyRSS2Gen.RSS2) PyRSS2Gen .RSS2(**valid_kwargs) 

我可能會從有效的關鍵字參數列表中過濾字典,但我想知道:有沒有辦法 pr以圖形方式列出特定函數採用的關鍵字參數?

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

News


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method