使用python 3.x 对pythonchallenge-----2的解答过程

pythonchallenge-2地址 : http://www.pythonchallenge.com/pc/def/ocr.html
图片如下:

题目解析:完全看不明白什么意思。通过攻略确定题目意思:在页面源代码中有一段乱码,找到乱码中出现次数最少的字符。
解题过程:
file_obj = open(r'./other/chakkenge2.text')
try:
    straa = file_obj.read()
finally:
    file_obj.close()

list = []
key = []
lesschar = ""

for i in straa:
    list.append(i)
    if i not in key:
        key.append(i)

for j in key:
    print(j + "--- " + str(straa.count(j)))
    if straa.count(j) == 1:
        lesschar = lesschar + j

print(lesschar)

 答案:

e--- 1
q--- 1
u--- 1
a--- 1
l--- 1
i--- 1
t--- 1
y--- 1
equality

本题答案就是: equality

心得:我这里讲乱码全面放入到一个文本中进行解析。

 
 
原文地址:https://www.cnblogs.com/yinsjun/p/7463213.html