通过在 Python 3.6.3 中使用shlex模块,尝试通过空格拆分字符串,同时保留用大括号/智能引号 (“”) 括起来的内容。但是,它不能正常工作:
>>> import shlex
>>> text = 'one “two and three” four'
>>> shlex.split(text)
['one', '“two', 'and', 'three”', 'four']
使用普通引号 ("),按预期工作:
>>> text = 'one "two and three" four'
>>> shlex.split(text)
['one', 'two and three', 'four']
那么,如何让 shlex 使用 qurly/智能引号?