有 6 个测试用例,其中 5 个基于 python 3 在字符串操作问题上通过,但 1 个测试用例自开始以来就失败了。请帮帮我。问题如下:一个函数中给出了8个字符串。
- 从字符串的两端删除空格:first、second、parent、city
- 大写 : first, second, parent
- 打印带空格的字符串:first、second、parent、city
- 检查字符串:“电话”是否仅包含数字
- 检查电话号码是否以字符串“start”中的值开头并打印结果(真或假)
- 打印:总数 'strfind' 出现在字符串中的次数:第一、第二、父母、城市
- 打印:在 'string1' 上使用 split 函数生成的列表
- 在“城市”中查找“strfind”的位置
我的代码如下:让我知道我做错了什么。5/6 个测试用例通过,只有 1 个测试用例因未知原因失败。:(
def resume(first, second, parent, city, phone, start, strfind, string1):
first = first.strip()
second = second.strip()
parent = parent.strip()
city = city.strip()
first = first.capitalize()
second = second.capitalize()
parent = parent.capitalize()
print(first + " " + second + " " + parent + " " +city)
print(phone.isdigit())
print(phone[0]==start[0])
res = first + second + parent + city
res_count = res.count(strfind)
print(res_count)
print(string1.split())
print(city.find(strfind))