Python
zhengxu4665
这个作者很懒,什么都没留下…
展开
-
MIT-6.00.1x-L11-P6
class Queue(object): def __init__(self): self.queue = [] def insert(self,e): self.queue.append(e) def remove(self): try: return self.queue.pop() exc原创 2015-07-29 15:57:04 · 594 阅读 · 0 评论 -
python 字典合并
dict1={1:[1,11,111],2:[2,22,222]}dict2={3:[3,33,333],4:[4,44,444]}合并两个字典得到类似{1:[1,11,111],2:[2,22,222],3:[3,33,333],4:[4,44,444]}方法1:dictMerged1=dict(dict1.items()+dict2.items())方法2:转载 2015-07-30 00:44:18 · 358 阅读 · 0 评论 -
python for else primers
>>> for n in range(2, 10):... for x in range(2, n):... if n % x == 0:... print n, 'equals', x, '*', n/x... break... else:... print n, 'is a prime n转载 2015-07-30 08:09:07 · 372 阅读 · 0 评论 -
What does __init__ == __main__ mean?
When your script is run by passing it as a command to the Python interpreter,python myscript.pyall of the code that is at indentation level 0 gets executed. Functions and classes that are define转载 2015-07-29 23:33:54 · 628 阅读 · 0 评论 -
python list to string
["a", "b", "c", “d“]转换成abcd"".join(s)Use the join method of the empty string to join all of the strings together with the empty string in between, like so:>>> a = ['a', 'b', 'c', '转载 2015-07-30 01:03:42 · 686 阅读 · 0 评论 -
Rice- IIIP (2)
avoid unnamed constant在codesculptor直接运行Mac: Alt-Left/Right Windows: Ctrl-Left/Right move by wordselecting line shift+down原创 2015-08-01 19:48:48 · 505 阅读 · 0 评论 -
Rice-IIIP (1)
d原创 2015-07-31 16:31:04 · 702 阅读 · 0 评论