如何将字符串拆分-s -k "test_a or test_b" -m "not unstable" --results=/tmp/test-results --log-cli-level=INFO
为
['-s', '-k', 'test_a or test_b', '-m', 'not unstable', '--results=/tmp/test-results', '--log-cli-level=INFO']
我假设您错过了加引号。如果要拆分类似shell的行为,请使用shlex
:
import shlex
s = '-s -k "test_a or test_b" -m "not unstable" --results=/tmp/test-results --log-cli-level=INFO'
print(shlex.split(s))
# ['-s', '-k', 'test_a or test_b', '-m', 'not unstable', '--results=/tmp/test-results', '--log-cli-level=INFO']
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句