str = '''Hello world! Whats up?'''
rangeSplitLiast = [range(5, 11), range(18, 21)]
我需要下面的输出:
Hello world!
怎么了?
您可以尝试类似:
str1 = '''Hello world! Whats up?'''
rangeSplitLiast = [str1[0:12], str1[13:21]]
for string in rangeSplitLiast:
print(string, end="\n\n")
输出:
Hello world!
whats up?