随笔分类 -  Python

摘要:def triangles(): prev_line = [1] while True: yield prev_line result = [1] if len(prev_line) == 1: result.append(1) if len(prev_line) > 1: for i in ran 阅读全文
posted @ 2018-05-16 14:50 Benguoby2 阅读(87) 评论(0) 推荐(0)
摘要:答案参考了谈论中的答案。 阅读全文
posted @ 2018-03-26 19:58 Benguoby2 阅读(168) 评论(0) 推荐(0)
摘要:import copy 假设在python中对list的复制 copy称为浅复制 deepcopy称为深复制 浅复制和深复制在一般的list中作用是相同的,都是进行一个复制 但是在list嵌套list中就会有区别 比如: a = [1,2,[3,4]] b = copy.copy(a) c= cop 阅读全文
posted @ 2018-03-17 16:38 Benguoby2 阅读(542) 评论(0) 推荐(0)
摘要:# -*- coding: utf-8 -*-import string def extend_word(text): if text.find('\'') > 0: old2new = dict() words = text.split() for word in words: if word.f 阅读全文
posted @ 2018-03-17 12:40 Benguoby2 阅读(221) 评论(0) 推荐(0)