wujunkai 当前离线
六级士官
import re str = "this is string ? example....wow!!! this is really string" print re.sub(r'(?<=[?|?]).+','',str)复制代码
TOP
#!/usr/bin/python # -*- coding: UTF-8 -*- import re str = "this is string ?example....wow!!! this is really string" str = re.sub(r'(?<=[?|?]).+','',str) if str[-1]!='?' : str=str[:-1]+'?' print str复制代码