【发布时间】:2017-11-16 14:03:05
【问题描述】:
如何将字符串返回到某个字符?
def get_header(s):
'''(str) -> str
Return the start of the given string upto and including
</head>.'''
return (s.split('</head>')[0])
这就是我所做的,但是,我不知道如何在 """" 之前获得所有内容并包括它。
例如:
s ="hello python world </head> , i'm a beginner "
get_header(s)
这会返回
"hello python world "<"/head">" #without the quotient marks around the <
【问题讨论】:
-
发布示例输入和预期输出。
标签: python string python-3.x