Y
Y
YUMp2021-10-19 17:15:16
Python
YUMp, 2021-10-19 17:15:16

TypeError: 'NoneType' object is not callable why does it occur?

running python code

for  el in html.select("#d_clip_button > span"):
     msg.attach(MIMEText(el, 'plain'))
     el = el.translate({ord(i): None for i in '<span>, /'})
     print(el)

Tell me why it shows
el = el.translate({ord(i): None for i in ', /'})
TypeError: 'NoneType' object is not callable

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-10-19
@galaxy

What's a parser?
The elements selected by select() are not strings, but objects of the bs4.element.Tag class with complex internal behavior. In particular, they intercept access to attributes through a dot and return None for non-existent attributes. They don't have a translate attribute/method.
What did you want to do in general?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question