Don't split double-quoted words with Python string split()?

前端 未结 3 1589
感动是毒
感动是毒 2020-12-20 13:17

When using the Python string function split(), does anybody have a nifty trick to treat items surrounded by double-quotes as a non-splitting word?

Say I want to spli

3条回答
  •  清酒与你
    2020-12-20 13:31

    I suggest you search with re for the pattern "[^"]*" and apply string.split only on the remaining parts. You could implement a recursive function that processes all relevant string parts.

提交回复
热议问题