|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
a=""
b=[a[0]] #种类序列
def zhonglei (): #种类
global b
for i in a:
if i not in b :
b.append (i)
def geshu (): #个数
for c in range (len(a)+1):
gs = a.count(b[c])
if b[c]=="\n":
print ("""\\n的个数:%s"""%gs)
else:
print ("""%s的个数:%s"""%(b[c],gs))
geshu()
def zifu():
for c in range (len(a)+1):
if a[c].isalpha() :
print (a[c],end="")
continue
pass
zhonglei()
zifu()
运行后结果:
%的个数:6104
$的个数:6046
@的个数:6157
_的个数:6112
^的个数:6030
#的个数:6115
)的个数:6186
&的个数:6043
!的个数:6079
+的个数:6066
]的个数:6152
*的个数:6034
}的个数:6105
[的个数:6108
(的个数:6154
{的个数:6046
\n的个数:1218
G的个数:1
O的个数:2
D的个数:1
L的个数:1
U的个数:1
C的个数:1
K的个数:1
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\20.0未完成(报错).py", line 1244, in <module>
zhonglei()
File "C:\Users\Administrator\Desktop\20.0未完成(报错).py", line 1234, in zhonglei
geshu()
File "C:\Users\Administrator\Desktop\20.0未完成(报错).py", line 1229, in geshu
gs = a.count(b[c])
IndexError: list index out of range
@小甲鱼
第一,编程要养好良好的编程习惯,尽量避免使用拼音等,不会的单词可以通过翻译软件进行翻译,记住常用的就够了。
第二,你这个a一开始的时候是没有赋值的,你这个报错也是提示索引出现错误。IndexError: list index out of range。索引错误,列表索引超出范围。
第三个,如果以后需要写注释,请多写一点,不要那么的简单
第四个,你看看你的代码里面的那个个数是不是在重复递归调用
|
|