str = '''Hello world! Whats up?'''
rangeSplitLiast = [range(5, 11), range(18, 21)]
我需要以下输出:
世界你好!
怎么了?
答案 0 :(得分:2)
您可以尝试以下操作:
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?