python
6丁一的猫
为时未晚
展开
-
TypeError: 'module' object is not callable 原因分析
程序代码 class Person: #constructor def __init__(self,name,sex): self.Name = name self.Sex = sex def ToString(self): return 'Name:'+self.Name+',Sex:'+self.Sex在I转载 2017-01-04 10:13:53 · 1245 阅读 · 0 评论 -
python基础之(map, filter,reduce,lambda,global 变量)
map(square, range(5)) Out[9]: [0, 1, 4, 9, 16] filter(f, sq) 函数的作用相当于,对于 sq 的每个元素 s,返回所有 f(s) 为 True 的 s 组成的列表,相当于:[s for s in sq if f(s)] In [10]: def is_even(x): return x % 2 == 0filter(is_even,原创 2017-12-22 11:16:54 · 336 阅读 · 0 评论 -
one_plus
#coding:utf-8 ''' Created on 2017-9-22@author: 刘帅 ''' def plus_1(num_arr): #print enumerate(num_arr) #print list(enumerate(num_arr)) #print reversed(list(enumerate(num_arr))) for idx, d原创 2017-09-22 14:02:38 · 271 阅读 · 0 评论 -
missing_range
#coding:utf-8 ''' Created on 2017-9-21@author: 刘帅 ''' ## find missing ranges between low and high in the given array. # ex) [3, 5] lo=1 hi=10 => answer: [1->2, 4, 6->10] def missing_ranges(nums,lo,hi):原创 2017-09-21 09:22:33 · 266 阅读 · 0 评论 -
merge_intervals
#coding:utf-8 ''' Created on 2017-9-20 """ Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. """''' class Int原创 2017-09-20 08:59:12 · 410 阅读 · 0 评论 -
two_sum
#coding:utf-8 ''' Created on 2017-9-28@author: 刘帅 ''' """ Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would原创 2017-09-28 08:37:11 · 288 阅读 · 0 评论 -
Pythonic Data Structures and Algorithms(Array 4)
# Given a string, find the length of the longest substring # without repeating characters.# Examples:# Given "abcabcbb", the answer is "abc", which the length is 3.# Given "bbbbb", the answer is "b", w原创 2017-09-19 08:59:48 · 399 阅读 · 0 评论 -
Three_sum
#coding:utf-8 ''' Created on 2017-9-27@author: 刘帅 ''' """ Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the原创 2017-09-27 08:52:19 · 312 阅读 · 0 评论 -
Pythonic Data Structures and Algorithms(Array 3)
#coding:utf-8 ''' Created on 2017-9-18@author: 刘帅 ''' # There is a parking lot with only one empty spot. Given the initial state # of the parking lot and the final state. Each step we are only allowed原创 2017-09-18 09:14:29 · 571 阅读 · 0 评论 -
Pythonic Data Structures and Algorithms(Array 2)
""" Implement Flatten Arrays. Given an array that may contain nested arrays, give a single resultant array. function flatten(input){ } Example: Input: var input = [2, 1, [3, [4, 5], 6], 7, [8]]; flatte原创 2017-09-17 11:02:56 · 280 阅读 · 0 评论 -
Pythonic Data Structures and Algorithms(Array 1)
Note:最近领带要求参加python培训课,趁这个机会顺便复习下。再巩固基础,现在machine leraning 和 deep leraning那一块用python的很多,所以还是很有必要的。(说道这里顺便说下,后续博主还会更新前端reactjs和angularjs的知识与实际项目。视觉化还是很有意思的~~) 从Array开始吧 经典题目: 围成圆形坐了一圈人,打印每第三个成原创 2017-09-17 09:49:36 · 231 阅读 · 0 评论 -
summary_ranges
#coding:utf-8 ''' Created on 2017-9-25''' def summary_ranges(nums): res = [] if len(nums) == 1: return [str(nums[0])] i = 0 while i < len(nums): num = nums[i] whi原创 2017-09-25 08:31:11 · 406 阅读 · 0 评论 -
subsets
#coding:utf-8 ''' Created on 2017-9-24@author: 刘帅 ''' def subsets(nums): res = [] backtrack2(res,nums,[],0) return resdef backtrack(res,nums,stack,pos): if pos == len(nums): res原创 2017-09-24 13:05:57 · 282 阅读 · 0 评论 -
rotate_array
#coding:utf-8 ''' Created on 2017-9-24@author: 刘帅 ''' def rotate_new_list(nums,k):#新开一个数组 t = [] for i in range(len(nums)): #print i #print (i + k)%7 t.insert((i + k)%7,原创 2017-09-24 11:19:41 · 211 阅读 · 0 评论 -
微信公众号机器人开发
假设有个场景,机器人帮助用户询问安装电视,对用户提出的安装预定进行自动记录和提取里面关键信息,比如姓名,电话,购买电视机型号,安装地址等。。这样可以节约许多的人力,使用机器人客服去自动提取这些信息。可以先看说明,再到github参考代码。 github链接如下:客服机器人链接 欢迎star,不了解可以提问哦 此机器人属于任务型目前仅仅对于电视安装预定部分,不像微软小冰等。 首先的以个人微信的原创 2017-12-14 17:29:11 · 1502 阅读 · 2 评论