2
我試圖用pyparsing匹配一個多行字符串,可以以類似的方式繼續與蟒蛇:的Python/Pyparsing - 多行報價
Test = "This is a long " \
"string"
我不能找到一種方法,使pyparsing承認這一點。以下是我試過到目前爲止:
import pyparsing as pp
src1 = '''
Test("This is a long string")
'''
src2 = '''
Test("This is a long " \
"string")
'''
_lp = pp.Suppress('(')
_rp = pp.Suppress(')')
_str = pp.QuotedString('"', multiline=True, unquoteResults=False)
func = pp.Word(pp.alphas)
function = func + _lp + _str + _rp
print src1
print function.parseString(src1)
print '-------------------------'
print src2
print function.parseString(src2)
謝謝,這是我所希望的! –