python

您所在的位置:网站首页 Python进制转换输出 python

python

2024-07-06 12:54| 来源: 网络整理| 查看: 265

PYTHON——查找指定字符

如梦是梦: def find_char_index(char, string): char = char.lower() string = string.lower() found = False index = -1 for i, c in enumerate(string): if c == char: found = True index = i break if found: return f"index = {index}" else: return "Not Found" char_to_find = input().strip() input_string = input().strip() if len(input_string) > 20: print("输入字符串超过20个字符,请重新输入。") else: result = find_char_index(char_to_find, input_string) print(result)



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3