如何在 Python 中读取字符串中的特定行?

问题描述 投票:0回答:0

如何从 Python 中的字符串中读取特定行?例如,假设我想要以下字符串的第 2 行:

string = """The quick brown fox 
jumps over the
lazy dog."""
line = getLineFromString(string, 2)
print(line)  # jumps over the

关于reading specific lines from a file有几个问题,但是我如何从字符串中读取特定行?

python line string-parsing
© www.soinside.com 2019 - 2024. All rights reserved.