• 使用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

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

     
     
  • 相关阅读:
    c# 字符串中某个词出现的次数及索引
    c# 冒泡排序
    WCF 高级知识
    Web Api基础知识
    Web Services基础知识
    WCF Demo
    IIS部署WCF常见错误
    IIS部署WCF
    IIS部署WCF错误
    WCF基础知识
  • 原文地址:https://www.cnblogs.com/yinsjun/p/7463213.html
Copyright © 2020-2023  润新知