新手求助 python input

2024-12-01 10:03:32
推荐回答(2个)
回答1:

import re
i1 = open('test.txt','r').read()
str_input = input("please input:")
i2 = re.findall(r"%s(.*?)hi"$str_input, i1, re.MULTILINE | re.DOTALL)
for i in i2:
print (i)
我没实验,你先看看行不行

回答2:

str =input()
i2 = re.findall(r""+str+"(.*?)hi", i1, re.MULTILINE | re.DOTALL)

字符串直接拼接就行