首页 > 解决方案 > 调用变量时的查询函数

问题描述

我想知道在使用变量时是否可以调用函数或动作。

我有文本变量:

text = "This is My text, and I would like HERE a Smiley, but i'm not satisfied, so I want here a smiley with sunglasses, and right after HERE I would like an emoji with a heart."

现在,由于 selenium 的事实,我必须使用 javascript injection 来放置表情符号,并且由于输入仍然不存在而在初始化变量时无法完成,有没有办法调用一个函数,其中 += 是已经输入的带有 unicode 文本的文本?字符串太多,无法为每个编写函数,带有表情符号的句子太多,无法一一写下来。

我想要完成的是这样的:

text = "I would like a " + emoji('heart') + " And that was great, but here I would like a " + emoji('sunglasses') + " And a magnificient" + emoji(unicorn)

这是在字符串中每个字母写字母的函数:(其中文本是键)

for key in keys:
 print(key)

其中,到达 emoji() 调用了在 innerHTML 中注入 += emoji 的函数。

我已经有了表情符号的 unicode 和所有东西,我错过了被调用一次的动态字符串函数调用,例如“我想要一个”已经被逐个字符写入,函数被调用,表情符号注入并且它继续编写细绳。

标签: pythonpython-2.7selenium

解决方案


推荐阅读