关闭

什么是:语法糖、语法盐、语法糖精

概述 名词 别称 英文名 解释 语法糖 糖衣语法 Syntactic sugar 指计算机语言中添加的某种语法,这种语法对语言的功能没有影响,但是更方便程序员使用。 语法盐 syntactic salt 指的是让写出坏代码更难的语法特性。这些特性强迫程序员做出一些基本不用于描述程序行为,而是用来证明他们知道自己在做什么的额外举动。 语法糖精 语...
阅读(7) 评论(0)

python: 迭代器 (Iterator)

概述迭代器(iterator)是访问集合内元素的一种方式,提供了一种遍历类序列对象的方法。从集合的第一个元素开始访问,直到所有的元素都被访问一遍后结束。对于字典、文件、自定义对象类型等,可以自定义迭代方式,从而实现对这些对象的遍历。总之,迭起器就是定义了对对象进行遍历的方式。凡是可作用于for循环的对象都是Iterable类型;凡是可作用于next()函数的对象都是Iterator类型,它们表示一个...
阅读(9) 评论(0)

python: iter、next函数

语法 iter(object[, sentinel]) next(iterator[, default]) 实验代码# -*- coding: utf-8 -*-# 首先获得Iterator对象: it = iter([1, 2, 'Hello', 'Nanjing', [10, 20]]) print type(it) print it # 循环: while True: try:...
阅读(13) 评论(0)

python: hasattr()、setattr()、getattr()、delattr() 内建函数

Func Func 语法 作用 retype hasattr hasattr(object, name) 判断 对象中是否含有 该属性。 True / False setattr setattr(object, name, values) 给对象的属性 赋值,若属性不存在,先创建再赋值。 None getattr getattr(object,...
阅读(198) 评论(0)

leetcode: 50. Pow(x, n)

QImplement pow(x, n). Example 1:Input: 2.00000, 10 Output: 1024.00000 Example 2:Input: 2.10000, 3 Output: 9.26100 ACclass Solution(object): def myPow(self, x, n): """ :type x: float...
阅读(25) 评论(0)

leetcode: 49. Group Anagrams

QGiven an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"] ] Note: All inputs will...
阅读(19) 评论(0)

leetcode: 48. Rotate Image

QYou are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise). Note:You have to rotate the image in-place, which means you have to modify the input 2D matrix direct...
阅读(22) 评论(0)

leetcode: 47. Permutations II

QGiven a collection of numbers that might contain duplicates, return all possible unique permutations. ExampleFor example, [1,1,2] have the following unique permutations: [ [1,1,2], [1,2,1], [2,1...
阅读(67) 评论(0)

leetcode: 46. Permutations

QGiven a collection of distinct numbers, return all possible permutations. ExampleFor example, [1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1...
阅读(22) 评论(0)

python: argparse库 & 命令行解析工具

API ArgumentParser.add_argument(name or flags…[, action][, nargs][, const][, default][, type][, choices][, required][, help][, metavar][, dest])name or flags - 选项字符串的名字或者列表,例如 foo 或者 -f, –foo。 action...
阅读(185) 评论(0)

leetcode: 45. Jump Game II

QGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to rea...
阅读(102) 评论(0)

leetcode: 44. Wildcard Matching

QImplement wildcard pattern matching with support for ‘?’ and ‘*’.'?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence).The matching should cover the e...
阅读(104) 评论(0)

leetcode: 43. Multiply Strings

QGiven two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2. Note:The length of both num1 and num2 is < 110. Both num1 and num2 contains only digits 0-9....
阅读(87) 评论(0)

leetcode: 42. Trapping Rain Water

QGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], ret...
阅读(80) 评论(0)

leetcode: 41. First Missing Positive

QGiven an unsorted integer array, find the first missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant space. AC...
阅读(77) 评论(0)
323条 共22页1 2 3 4 5 ... 下一页 尾页
    快捷搜索
    Google 本站
    个人资料
    • 访问:59162次
    • 积分:3890
    • 等级:
    • 排名:第9138名
    • 原创:320篇
    • 转载:3篇
    • 译文:0篇
    • 评论:20条
    博客专栏
    文章分类