Python抓取页面乱码问题的解决
摘要:import urllib2response=urllib2.urlopen('http://house.focus.cn/')html=response.read()print html.decode('gbk')
阅读全文
python拼接字符串
摘要:可以用+, 跟C#一样,效率有问题,用join,join的用法如下:print '张三丰'.join('lisi') 打印出的会是:l张三丰i张三丰s张三丰i那么要拼接怎么搞呢?for d in os.listdir('d:\\'): print ':::'.join([d,'file' i...
阅读全文
SyntaxError: Non-ASCII character '\xe5' in file a.py on line 9, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
摘要:SyntaxError: Non-ASCII character '\xe5' in file a.py on line 9, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details在文件头...
阅读全文
Python三目运算符
摘要:result=x if x<y else y这种方式,简单直观。
阅读全文