|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 丶霁灵 于 2020-2-20 16:15 编辑
如题,本人在做零基础课后作业20,以下是代码:
------------------------------------------------------------------------
def findstr0(str0=''):
str1 = ''
for i in str0:
if i not in str1:
str1 += i
str2 = sorted(str1)
for i in str1:
a = str0.count(i)
print('字符',i,'出现的次数为',a,' ')
temp = input('请输入需要检索的字符串:')
temp = temp.replace('\n','')
findstr0(temp)
------------------------------------------------------
红色部分是我后加进去的,但是我发现还是没用,所以我觉得,从input的时候就只有一行了
请问该怎么解决??
【萌新提问,如有违规请速度删帖】
--------------------------------------------------
def findstr0(str0=''):
str1 = ''
for i in str0:
if i not in str1:
str1 += i
str2 = sorted(str1)
for i in str1:
a = str0.count(i)
print('字符',i,'出现的次数为',a,' ')
str3 = ''
print('请输入要检索的字符串:',end='')
while 1:
temp = input()
if temp == 'over':
break
str3 += temp
findstr0(str3)
-------------------------------------------------
原来复制来的回车我自己输入的回车是一样的概念,所以这样就好了
|
|