小编use*_*061的帖子

字符串比较失败

output = subprocess.check_output("./mount.sh", shell=True)
print output
if output == "expected_String":
      print "Hurray!"
Run Code Online (Sandbox Code Playgroud)

(打印命令只是为了检查输出是否符合我的预期)。每次比较都失败,我不明白为什么。我用这个而不是 check_output 试过了

(stdout, stderr) = Popen(["./mount.sh"], stdout=PIPE).communicate()
mountout = stdout
Run Code Online (Sandbox Code Playgroud)

但我不认为这是这里的问题,因为

 print output
Run Code Online (Sandbox Code Playgroud)

给了我我的期望,但如果我尝试将它与我的“expected_String”进行比较,它总是错误的。

python string comparison

2
推荐指数
1
解决办法
7452
查看次数

标签 统计

comparison ×1

python ×1

string ×1