【发布时间】:2020-11-30 23:05:39
【问题描述】:
我想在一个文本文件中查找所有引用的语句。我写了一个代码,它可以找到第一个引用的语句。但是,当我使用 while 循环 时,它可以遍历整个文本并找到它们,但它不起作用。 这是代码:
quoteStart = fullText.index("\"")
quoteEnd = fullText.index("\"", quoteStart + 1)
quotedText = fullText[quoteStart:quoteEnd+1]
print ("{}:{}".format(quoteStart, quoteEnd))
print (quotedText)
输出:
250:338
"When we talk about the Hiroshima and Nagasaki bombing, we never talk about Shinkolobwe,"
如何添加 while 循环来遍历整个文本?
【问题讨论】:
标签: python text while-loop quotes