Python-如何制作动态方法

问题描述

我想知道如何为变量分配动态方法(例如“ .text”或“ .split()”)。

some_selector = "div.test"      # is it possible to add here a method? For example ".text"
soup.select_one(some_selector).text   # It would work,i want to achieve this,but in line above ( i don't want to have .text in this line).

理想的解决方案(但不起作用)

some_selector = "div.test".text  # i added at the end of the sentence method
soup.select_one(some_selector)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)