1. 字母a的出现次数: def count_a(s): return s.count('a') string1 = input("请输入一个字符串:") print(f"字母a的出现次数是:{count_a(string1)}") 2. 替换'py'为'python': def replace_py(s): return s.replace('py', 'python') string2 = input("请输入一个带有py的字...
【编程题】输入一个带有字母 a 的字符串,输出其中字母 a 的出现次数。 示例1 : 输入: "The python language is a multimodel language." 输出:"5"答案 x = str(input('please enter whatever you want: ')) print(x.count('a')) count = 0 # 实现count函数的功能 for i in ra...