![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
AceFreeze
这个作者很懒,什么都没留下…
展开
-
Python checkio Monkey Typing解决方案
def count_words(text, words): count = 0 for word in words: if text.lower().count(word): count +=1 return count原创 2017-12-08 17:17:45 · 806 阅读 · 0 评论 -
Python checkio Boolean Algebra解决方案
方法1OPERATION_NAMES = ("conjunction", "disjunction", "implication", "exclusive", "equivalence")def boolean(x, y, operation): if operation == OPERATION_NAMES[0]: return x and y if oper原创 2017-12-12 16:53:05 · 304 阅读 · 0 评论 -
Python checkio "Ghosts age"解决方案
def checkio(opacity): fibolist = getfibo() print(fibolist) startnum = 10000 for number in range(1,5000): if startnum == opacity: return number-1 if number i原创 2017-12-12 17:31:28 · 240 阅读 · 0 评论 -
Python爬虫 爬取糗事百科段子
使用Python urllib爬取糗事百科段子import reimport urllib.requestdef getcontent(url,page): #模拟成浏览器 headers = ('User-Agent','Mozilla/5.0 (Windows NT 10.0; WOW64; rv:57.0) Gecko/20100101 Firefox/57.0')原创 2017-12-12 17:34:06 · 309 阅读 · 0 评论 -
Python 爬虫学习笔记
快速爬取网页importurllib.requesturl ='http://www.baidu.com'response = urllib.request.urlopen(url) 将爬取的内容保存到本地fhandle=open("C:/Work/python_work/python_spider_study/1.html","wb")fhandle.wr原创 2017-12-11 09:29:11 · 281 阅读 · 0 评论 -
Python checkio "Friends"解决方案
class Friends: def __init__(self, connections): self.connectlist = list(connections) def add(self, connection): b = False if connection in self.connectlist else self.connectli原创 2017-12-13 14:40:07 · 515 阅读 · 0 评论 -
Python checkio "Long Non Repeat"解决方案
def non_repeat(line): # your code here result = '' for i in range(len(line)): value = '' for j in range(i,len(line)): char = line[j] if char not in原创 2017-12-13 15:53:23 · 796 阅读 · 0 评论 -
Python checkio "Striped Words"解决方案
VOWELS = "AEIOUY"CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"def checkio(text): import string text = ''.join([' ' if char in string.punctuation else char for char in text ]) words = text.split()原创 2017-12-13 17:03:58 · 512 阅读 · 0 评论 -
Python checkio "Speech Module"解决方案
FIRST_TEN = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine","ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "ei原创 2017-12-13 18:30:50 · 539 阅读 · 0 评论 -
Python checkio "The Most Frequent Weekdays"解决方案
判断一年中星期几出现的频率最高获取那一年第一周和最后一周,取出的交集就是出现频率最高的,如果没有交集,则取其并集def most_frequent_days(year): import calendar import datetime firstweek = set(range(datetime.datetime(year,1,1).weekday(),7))原创 2017-12-14 15:25:15 · 471 阅读 · 0 评论 -
Python checkio "Making Change"解决方案
def checkio(price,denominations): coin_results = [0] * (price +1) for price_item in range(1, price + 1): coin_variants = [] for coin in [coins for coins in denominations if coi原创 2017-12-14 17:40:56 · 493 阅读 · 1 评论 -
Python checkio "IP Network: Route Summarization"解决方案
def checkio(data): bins = ["".join(bin(int(x))[2:].zfill(8) for x in line.split(".")) for line in data] mask = 0 binary = "" for i, v in enumerate(zip(*bins), 0): if len(set(v)原创 2017-12-14 19:09:10 · 489 阅读 · 0 评论 -
Python checkio Cipher map解决方案
我的解决方案:def recall_password(cipher_grille, ciphered_password): result ='' rangenumber = len(cipher_grille) positionlist = [] [positionlist.append((i,j)) if cipher_grille[i][j] == 'X'原创 2017-12-12 16:31:00 · 597 阅读 · 0 评论 -
Python checkio Digits Multiplication解决方案
def checkio(number): numbercount = 1 for value in str(number): if value != '0': numbercount*=int(value) return numbercount原创 2017-12-08 17:30:53 · 506 阅读 · 0 评论 -
Python checkio Pawn Brotherhood解决方案
def safe_pawns(pawns): safe = 0 for p in pawns: row = int(p[1])-1 col1 = ord(p[0])-1 newpawn1 = str(chr(col1))+str(row) col2 = ord(p[0])+1 newp原创 2017-12-08 17:18:51 · 500 阅读 · 1 评论 -
Python checkio Min and Max解决方案
def min(*args, **kwargs): key=kwargs.get('key') if len(args)==1: result = sorted(args[0], key=key, reverse=False)[0] else: result = sorted(args, key=key,reverse=False)[0原创 2017-12-08 17:21:44 · 266 阅读 · 0 评论 -
Python checkio Long Repeat解决方案
在这里你应该找到字符串中最长的相同字符重复出现的次数,并返回它的重复次数。例如:字符串“aaabbcaaaa”包含具有相同字母“aaa”,“bb”,“c”和“aaaa”的四个子字符串。 最后一个子字符串是最长的一个字符串,你应该返回 4 。输入: 一个字符串.输出: 一个整数. def long_repeat(line): count =0 for char i原创 2017-12-08 17:23:26 · 1056 阅读 · 0 评论 -
Python checkio First Word解决方案
def first_word(text: str) -> str: import re pat1 = "[a-zA-Z']+" result = re.search(pat1,text) result = str(result.group()) return result原创 2017-12-08 17:25:38 · 1200 阅读 · 0 评论 -
Python checkio Secret Message解决方案
def find_message(text): secretmessage = '' for char in text: if char.isalpha() and char.upper() == char: secretmessage += char return secretmessage原创 2017-12-08 17:27:04 · 504 阅读 · 0 评论 -
Python checkio Index Power解决方案
def index_power(array, n): if len(array) > n: number = get_pow(array[n],n) else: number = -1 return numberdef get_pow(a,b): number=1 for i in range(b):原创 2017-12-08 17:28:25 · 445 阅读 · 0 评论 -
Python 链接爬虫
importreimport urllib.requestdef getlink(url): headers = ('User-Agent','Mozilla/5.0 (Windows NT 10.0; WOW64; rv:57.0) Gecko/20100101 Firefox/57.0') opener = urllib.request.build_op原创 2017-12-11 09:32:08 · 240 阅读 · 0 评论 -
Python checkio Days Between解决方案
def days_diff(date1, date2): import datetime return abs(( datetime.date(date1[0],date1[1],date1[2])-datetime.date(date2[0],date2[1],date2[2])).days)原创 2017-12-11 11:16:18 · 471 阅读 · 0 评论 -
Python checkio median解决方案
def function1(numberlist): import numpy return numpy.median(numberlist)def function2(numberlist): import statistics as stats return stats.median(numberlist)def function3(numberlist原创 2017-12-11 10:52:14 · 471 阅读 · 0 评论 -
Python checkio "Building Base"解决方案
学习基本的构造类及类中的函数class Building: def __init__(self, south, west, width_WE, width_NS, height=10): self.south = south self.west = west self.width_WE = width_WE self.原创 2017-12-15 14:44:40 · 340 阅读 · 0 评论