摘要: print(foo[不能是空,不能是字母如a或‘a’,可以是0,1,2])去了print,foo[i或数字]输出'a''b''c'(带引号)foo='abc' 阅读全文
posted @ 2015-07-08 18:02 hhj187 阅读(251) 评论(0) 推荐(0) 编辑
摘要: >>> foo='abc' 阅读全文
posted @ 2015-07-07 17:58 hhj187 阅读(128) 评论(0) 推荐(0) 编辑
摘要: what+'空格'*4,结果是后面四个空格>>> who='k'>>> what='Ni!'>>> print('we are hte %s who say %s'%(who,((what+' ')*4)))we are hte k who say Ni! Ni! Ni! Ni! >>> print... 阅读全文
posted @ 2015-07-07 17:31 hhj187 阅读(345) 评论(0) 推荐(0) 编辑
摘要: 这个星期开始学习Python了,因为看的书都是基于Python2.x,而且我安装的是Python3.1,所以书上写的地方好多都不适用于Python3.1,特意在Google上search了一下3.x和2.x的区别。特此在自己的空间中记录一下,以备以后查找方便,也可以分享给想学习Python的frie... 阅读全文
posted @ 2015-07-06 21:04 hhj187 阅读(103) 评论(0) 推荐(0) 编辑
摘要: print语句默认每行添加一个换行符item是列表当item是元组时,本题运行结果是一样的>>> for item in ['e','n','h','c']: print(item) enhc>>> print(item,end=)SyntaxError: invalid syntax>... 阅读全文
posted @ 2015-07-06 20:58 hhj187 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 先输出到2,后输出到3c=0赋值过了 再写程序还得写c=0 不晓为什么 阅读全文
posted @ 2015-07-06 18:27 hhj187 阅读(156) 评论(0) 推荐(0) 编辑
摘要: x=5是全局变量,f(x)的x是本地绑定,无论f(几)都不影响最后x永远是5 阅读全文
posted @ 2015-07-03 18:00 hhj187 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑