markup = '<a href="http://example.com/">\nI linked to <i>example.com</i>\n</a>'
soup = BeautifulSoup(markup)
soup.get_text()
u'\nI linked to example.com\n'
soup.i.get_text()
u'example.com'
>>> from bs4 import BeautifulSoup
>>> html = '<a href="http://example.com/">\nI linked to <i>example.com</i>\n</a>'
>>> root = BeautifulSoup(html, 'html.parser')
>>> root.get_text()
# '\nI linked to example.com\n'
>>> root.i.get_text()
# 'example.com'
Читайте про позиционные (кортежи) и именованные (словари) аргументы.
def func(*args, **qwargs):
if args:
sum = 0
for i in args:
sum += i
print(sum)
if qwargs:
sum2 = 0
for v in qwargs.values():
sum2 += v
print(sum2)
func(1, 2) #3
func(a=1, b=2) #3