Python TypeError不支持的%:'file'和'unicode'的操作数类型 [英] Python TypeError unsupported operand type(s) for %: 'file' and 'unicode'
本文介绍了Python TypeError不支持的%:'file'和'unicode'的操作数类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在进行django字段验证,我无法弄明白为什么我会收到此部分的类型错误:
I'm working on a django field validation and I can't figure out why I'm getting a type error for this section:
def clean_tid(self):
data = self.cleaned_data['tid']
stdout_handel = os.popen("/var/www/nsmweb/jre1.6.0_14/bin/java -jar /var/www/nsmweb/sla.jar -t %s grep -v DAN") % data
result = stdout_handel.read()
我可以转换数据,我可以作为字符串变量传递它吗?
Do I have to convert data somehow before I can pass it in as a string variable?
推荐答案
检查你的括号。
错误
stdout_handel = os.popen("/var/www/nsmweb/jre1.6.0_14/bin/java -jar /var/www/nsmweb/sla.jar -t %s grep -v DAN") % data
可能是对的。
stdout_handel = os.popen("/var/www/nsmweb/jre1.6.0_14/bin/java -jar /var/www/nsmweb/sla.jar -t %s grep -v DAN" % data )
这篇关于Python TypeError不支持的%:'file'和'unicode'的操作数类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文