使用shlex.split()?
s = "SOME_VAR="value with spaces" VAR2=value2"
shlex.split(s)
['SOME_VAR=value with spaces', 'VAR2=value2']
谢谢
您选择的python工具可能不是最佳的。
怎么样:
$ cat /tmp/tmp.py
import csv
import StringIO
s = "SOME_VAR="value with spaces" VAR2=value2"
reader = csv.reader(StringIO.StringIO(s), csv.excel)
for i in reader:
print i
$ python /tmp/tmp.py
['SOME_VAR="value with spaces" VAR2=value2']