Python TypeError unsupported operand type(s) for %: 'file' and 'unicode'

前端 未结 2 1771
闹比i
闹比i 2021-01-26 16:36

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_da         


        
相关标签:
2条回答
  • 2021-01-26 16:53

    Just a small tip - it's better to use subprocess module and Popen class instead of os.popen function. More details here (docs).

    0 讨论(0)
  • 2021-01-26 16:58

    Check your parenthesis.

    Wrong

    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
    

    Might be right.

    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 )
    
    0 讨论(0)
提交回复
热议问题