如何在python中从fonction cgi.escape()获取str

2024-05-16 04:36:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从php文件中恢复值字符串,以便在python中使用cgi模块

在my file.php中,我有:

<input type="password" name="pwd"> 

然后在我的文件.cgi中,我想获取密码并转义speciales字符:

formulaire = cgi.FieldStorage()
pwdStr = cgi.escape(formulaire.getValue("pwd"))

我不想在带有参数的其他函数中使用pwdStr,但pwdStr的类型不是str。如何转换为str?我试过:

pwdStr = str(cgi.escape(formulaire.getValue("pwd")))

但是没有起作用

有人能帮我吗? 巴西亚


Tags: 模块文件字符串inputmytypepwdfile