《小甲鱼零基础学Python》020课后作业题:找隐藏…
2018-08-26 17:32:52来源:博客园 阅读 ()
动动手:
1. 请用已学过的知识编写程序,找出小甲鱼藏在下边这个长字符串中的密码,密码的埋藏点符合以下规律:
a) 每位密码为单个小写字母
b) 每位密码的左右两边均有且只有三个大写字母
ACFlCTLIQlAIVMTqHFkswqbDDHtpgcWaXSSglUYKE lqNsYCyaQXBzrFUbkAUAWAKrDgDtAlGMBqWQhpEwquZqWZJpslUfMllCwWptqINjrOBTLuPzwvXNbLCx oFRritKRpJgBOaGPZdkUzvYnvYmAlEsVmKRXqyQUOdCBqLYyboOYeAQNLnkuiDXCiNiksSSRpDMVQQgs TmYThnppfKSmkpjjceGLaMOvYgsvNkGENKgGtUSzVPlLMeephDKrWGNpAxBqRiCnQIuKwDZurIRsznUp xhstMWpHdZzqeEnttlAHiWbhbIJpwKBAGsFWthBiwBDKTFzIUamELZJFLbmqOmwBIYBJIofAUyxTLUEm LcOXzjIHFcfUfEWccbWzhVuIZMdTVsOaNsLTpHjrvFaYTnJUrqaYnUmbobfOXXtkjKjFUEhVNlPWeaIY uABNuEDKFWiUaqQiBHGsgEmDSKiJKLkkzFWlobXIyUlDzGcwDnEOwwWxgFpebsslmKItazIYctPROSJp ImDHusQIkoFQSmuqwdcPNERvflfHtkGTrtbQXqZUsazoxmbVTPIuuxKvfALAaGnIuIZwczCcoIRMncBs timFGHPJPaHMPTLjsBjIwbbzKyghaDTUStzJceaYAneywwpvdiUJifPHtXmAwZPChWsDmwonzeeQCEiB xWsJLAtrdVEOBxEaYiSabHdUwlXlDOAKzZUwozJoBGvnFttDkXdYdjQSzzhTIPfYpWVFdiFIqSbyPZIi VoXunBPbAJVMWluPcIfHmjPeHaTyClCvTOucEYEZXbVDiZMsfeuruDGMmQEsHutzvzVmWvCoPRguBiHh taTeaguPmNuAxzYJLEcdoApfIFBaLUqettjTJNlHZYlJZRRoKXEvFnoUHdPjDuXuTAubGODkHAokpItw SlEwhjrUSlfMawWlTMciWA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iBcrPhaphSCB StQiJvtoPhHcLUbriDUIfifVFnNtJfGlmcbQJSXsZfVjpbqnkMllUmHzLvEuSarSlNlNHsWvYlfhjMEA epYTjoRGZeAAtURFeDfDxTYmOmONuQQBdcdncFGjhHmKlwqmUWoXuIXIxaaXnNThgPGtIlynrUIPLQTG xXhattDrfBGbZRveKbgjzxJLdYREQlMeLtcIEUoyJocdAfUbymxuFLVjGkOQniiPParqoyQYfDYAQTkM WLicLxpEFkBbwlKrTyYilKTtYkpVGxtOjYmcBDOrwFhFiGutmpTyTarUbVUeSevBTdaPDpjRkaEmLJMg WsMhSGfIcBChcqrRKgKpjvGnFipjswgjetRtniMagakbCXAjpzWTtMlgZGCJwGyglpcLebrKWhgwJfWV qGifWNEpCtjuejHoyVCdIxzMYGnfoslgTNAJdtVBWDVoGLzHSAVBTnhNIvAOExQNiJOIPPiHkdaRbfaP ixDDoCDOOeAqvQJFxLWDICfGmufyxmaMshbvcrtjqqVtffZTnbtCOQfzRMGwOQEKaAmSWjnYdNgvdkmd dQmaKZSdqKNrnvJlcyVMKuNWmuoOeyKecgjXbmSqnpjwJEaDYoehEklEgJyiksGxdEKgfYRXQecRZgfe qKWGc
第一次看题,觉得简单,于是写出以下代码:
- l = len(a)
- for i in range(3, l - 3):
- if a[i].islower():
- for j in range(1, 4):
- if a[i + j].isupper() + a[i - j].isupper() == 2:
- if a[i + 4].isupper() + a[i - 4].isupper() == 0:
- print(a[i], end = '')
结果如下:
- asaazzllqqqpbbiidllmmbbismrrppqqrzpztijjcntjauuiiiooyaasookttqqfaauconeitwwhhoddduaayyvzmoumfaallldubbkkkljlqzqyyarrswvapxmcoqzftzwwhhggfrzzoootvvoyfasgnebxxllvvrrghwsvvvzojbooiwwffyhhptqqzqseeenzmmyxlwwthhodcvyyvjwdccbmtnfcifenpzhhqvwclfffoozzwwowccbstuqivqmtenwwfnqkkvkknaljlegeffccnmeebiisnuuflwkmazookbvtyjpeeddavxxttpprwwiiimmddzzgbooddbbguyiikljdzzvvharxgukyyojtqqcchdlsubnfniuuzzqhljiwdtccfyuunldaagscjsssxtnoysfkhoocxgfuymmcxooqiblufovmddgvjxalhwwdddemtccyyuhqqppddirfyeouuaamznaabnlfphhwzgxuzzaycfewyvqqppvuuwwnnwwyfwwddssjhuppvvmmvvfjdczgkkhuutrjffyvvggvvzfhhhzzaddcczqjxifekxxhpggracllvvivccllppxbthjulrqqggxjuthamgttvjwwgenhvqggkkqceyyhhdfzlyyieruxcbbqqxxjoouuovcrrjnnesjnddazznmhhecffajppzebbppktfdtkkdendnsqqbbcvccchhrivocnfzzvvooeehqxntbbodfiiklritidapgvnnlbffpuvvfifnaddnyuuuaaed
这哪是什么密码,简直就是乱码,找了半天没找到原因,死马当活医,于是将代码修改如下:
- l = len(a)
- for i in range(3, l - 3):
- if a[i].islower():
- if a[i + 1].isupper() + a[i - 1].isupper() == 2:
- if a[i + 2].isupper() + a[i - 2].isupper() == 2:
- if a[i + 3].isupper() + a[i - 3].isupper() == 2:
- if a[i + 4].isupper() + a[i - 4].isupper() == 0:
- print(a[i], end = '')
结果如下:
- ilovefishc
1.小写字母前后的第4个为小写字母
2.小写字母前后的第j个为大写字母
应该改为小写字母前后的3个都为大写字母,直接上代码:
- l = len(a)
- x = 0
- for i in range(3, l - 3):
- if a[i].islower():
- if a[i + 4].isupper() + a[i - 4].isupper() == 0:
- for j in range(1, 4):
- if a[i + j].isupper() + a[i - j].isupper() == 2:
- x = 1
- else:
- x = 0
- break
- if x == 1:
- print(a[i], end = '')
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- Python 递归计算分数数列 2019-04-25
- 课时49:魔法方法:生成器 2018-08-26
- 课时47:魔法方法:定制序列 2018-08-26
- 课时45:魔法方法:属性访问 2018-08-26
- 课时44:魔法方法:简单定制 2018-08-26
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash