如何解决Python定义函数时传参遇到的问题

2025-03-21 03:51:49
推荐回答(1个)
回答1:

直观点的做法可以这么来。
def test(html, a, **kwargs):
soup = BeautifulSoup(html, a, kwargs)

调用:
d = {
'from_encoding': 'gb18030',
'settings': 'mode1'}test(html, a, d)