假设我有一个字符串:
mystr = "my name is some good name"
# I want to split at white space except for the part "name is"
expectedoutput = ["my", "name is", "some", "good", "name"]
有无 shlex 怎么办?
我试图做的方式是:
Import shlex
def careful_split(inputstr, donot_split = "name is"):
strlex = shlex.shlex(inputstr, commenters =?, posit = ?)
strlex.wordchars = ?
#and other shlex function
return list(strlex)