更新时间:2022-12-03 15:35:59
我相信问题在于您的输出末尾包含其他换行符。您可以通过调用 .strip()
来删除它们:
I believe the problem is your output contains additional new line character at the end. You can fix it by calling .strip()
to remove those:
output = subprocess.check_output("./mount.sh", shell=True)
output = output.strip()
请考虑以下交互式会话:
Consider the following interactive session:
>>> s = '''hello\n'''
>>> s.endswith('\n')
True