这一章节我们来聊聊作用域基础
python在创建、改变或者查找变量都是在所谓的命名空间中进行,作用域指的就是命名空间
简单的说:就是这个变量可以被访问的范围
我们举一个比较容易理解的例子--函数
>>> def test():
x=1
print(x)
>>> x
Traceback (most recent call last):
File "", line 1, in
...
分类:
编程语言 时间:
2015-09-12 10:55:19
阅读次数:
165
QuestionGiven a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant dig...
分类:
其他好文 时间:
2015-09-11 06:45:53
阅读次数:
193
Python’s handling of default parameter values is one of a few things that tends to trip up most new Python programmers (but usually only once).What ca...
分类:
编程语言 时间:
2015-09-11 00:08:52
阅读次数:
366
Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie...
分类:
其他好文 时间:
2015-09-10 19:34:29
阅读次数:
159
Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ...
分类:
其他好文 时间:
2015-09-10 16:06:48
阅读次数:
101
Problem:Given a string, find the length of the longest substring T that contains at most 2 distinct characters.For example, Given s =“eceba”,T is "ece...
分类:
其他好文 时间:
2015-09-10 12:47:29
阅读次数:
210
Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ...
分类:
其他好文 时间:
2015-09-10 09:39:28
阅读次数:
144
本节将介绍base公共通用库中的containers,其包含堆栈、列表、集合、以及Most Recently Used cache(最近使用缓存模板)。 linked_list.h:一个简单的列表类型,通过模板实现,内部采用双链表的形式,有区别于c++标准模板库的std::list,它的使用方...
分类:
其他好文 时间:
2015-09-09 22:37:31
阅读次数:
317
题目连接http://acm.hdu.edu.cn/showproblem.php?pid=3371Connect the CitiesDescriptionIn 2100, since the sea level rise, most of the cities disappear. Though...
分类:
其他好文 时间:
2015-09-08 21:53:23
阅读次数:
167
题目连接http://acm.hdu.edu.cn/showproblem.php?pid=1061Rightmost DigitDescriptionGiven a positive integer N, you should output the most right digit of N^N....
分类:
Web程序 时间:
2015-09-08 19:57:56
阅读次数:
125