字符串压缩(游程编码)
程序员文章站
2024-03-14 14:03:46
...
写的比较麻烦
-
def yasuo(str1):
-
list1=list(str1);
-
len1=len(list1);
-
for s in list1:
-
n=0;
-
for i in range(len1):
-
if(list1[i]==s):
-
n+=1;
-
list1[i]=’ ‘;
-
if(s==’ ‘):
-
continue;
-
else:
-
print(s,n,end=”,sep=”)
-
str3=input(‘输入一个’);
-
yasuo(str3);
-
转载:https://blog.csdn.net/ybp1137287436/article/details/79479249