Python
muyuxuebaoTemp
发生发生的
展开
-
Python报错TypeError: 'str' object is not callable
当一般内部函数被用作变量名后可能出现此错误。比如: range=1 for i in range(0,1): ……… 就会报这样的错误 这样的错会报在for行,但是时间引起的原因却是在range=1这行,如果两行相距较远,怎很难被发现。所以要特别注意不要用内部已有的变量和函数名作自定义变量名。 或者str被预先定义了 str=10 f转载 2016-03-29 15:38:08 · 555 阅读 · 0 评论 -
python sorted
我们需要对List进行排序,Python提供了两个方法 对给定的List L进行排序, 方法1.用List的成员函数sort进行排序 方法2.用built-in函数sorted进行排序(从2.4开始) --------------------------------sorted--------------------------------------- >>> help(sorte转载 2016-03-29 15:41:21 · 225 阅读 · 0 评论 -
Python 实现倒排索引
git: https://github.com/muyuxuebao/reverseIndex # -*- coding:utf-8 -*- import re def token_stream(line): return re.findall(r'\w+', line, re.I) def mapper(lineNum, list): dic =原创 2016-03-29 17:05:48 · 4709 阅读 · 0 评论 -
Python基础教程
参考 http://www.runoob.com/python/python-chinese-encoding.html转载 2016-03-25 08:56:39 · 220 阅读 · 0 评论 -
Python print 不换行的方法
在末尾加一个 逗号 就可以了。 等你输完了,你又想换行的时候,单独一个 print 就换行了。试试看。转载 2016-03-26 18:46:49 · 559 阅读 · 0 评论 -
Python 原始字符串操作符(r/R)
原始字符串:所有的字符串都是直接按照字面的意思来使用,没有转义特殊或不能打印的字符。 原始字符串除在字符串的第一个引号前加上字母“r”(可以大小写)以外,与普通字符串有着几乎完全相同的语法。 如: >>> '\n' '\n' >>> print '\n' >>> r'\n' '\\n' >>> print转载 2016-03-29 09:46:57 · 2269 阅读 · 0 评论