|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
def findstr(destr,substr):
count = 0
length = len(destr)
if substr not in destr:
print('未找到相应字符串')
else:
for each1 in range(length - 1):
if destr[each1] == substr[0]:
if destr[each1+1] == substr[1]:
conut += 1
print('子字符串共出%d' % count)
destr = input('请输入目标')
substr = input('请输入两个字符串')
findstr(destr,substr)
Traceback (most recent call last):
File "C:/Users/11510/Desktop/aa.py", line 15, in <module>
findstr(destr,substr)
File "C:/Users/11510/Desktop/aa.py", line 10, in findstr
conut += 1
UnboundLocalError: local variable 'conut' referenced before assignment
问一下在运行时为什么会报错 我是对着答案打的 答案能运行 我这个就报错。。。。。。。。。。。
|
|