摘要: print(key,aDict[key])相当于名字和内容#print语句默认每行添加一个换行符,所以:>>> a={'host':'earth'}>>> a['port']=80>>> a{'host': 'earth', 'port': 80}>>> a('port')=80SyntaxErro... 阅读全文
posted @ 2015-06-29 21:58 hhj187 阅读(634) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2015-06-29 21:53 hhj187 阅读(143) 评论(0) 推荐(0) 编辑
摘要: >>> num=input()1234>>> num'1234'>>> num=input(haha:)SyntaxError: invalid syntax>>> num=input('haha:')haha:23>>> num'23'>>> print(num)23'>>> print(num)... 阅读全文
posted @ 2015-06-29 12:05 hhj187 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 递归:若函数包含了对其自身的调用,该函数为递归的。>>> #递归 《Python核心编程》P305>>> def factorial(n):if n==0 or n==1:#0!=1!=1return 1else:return n*factorial(n-1)>>> factorial(3)6>>>... 阅读全文
posted @ 2015-06-29 11:23 hhj187 阅读(190) 评论(0) 推荐(0) 编辑