明天

导航

随笔分类 -  python

编码错误设置错误报 "SyntaxError: Non-ASCII character '/xe6' "
摘要:无意中碰到键盘导致一段处理中文拼音的 python 代码跑起来报了个错“SyntaxError: Non-ASCII character ‘/xe6' "看了下是注释# coding: utf-8的冒号两边都被加了空格,去掉空格就好了,另外使用下面的注释也可以解决中文报错问题# This Python file uses the following encoding: utf-8 阅读全文

posted @ 2014-03-02 19:59 wuwb 阅读(482) 评论(0) 推荐(0)

更新 requests 包之后报 has no attribute '__getitem__' 的错
摘要:翻代码的时候看到段一年多前用 python 写的下载图片站图片的代码。测试下看还能不能下到图片,结果发现跑不起来了,报了个如下的错误:TypeError: 'instancemethod' object has no attribute '__getitem__'谷歌一下发现是 requests 包升级后不兼容老版本造成的解决方法是安装 requests-transition 这个包,pip install requests-transition然后如果你原来的代码中使用的是 requests 0.x 版本的话,将import requests改成import 阅读全文

posted @ 2014-03-02 18:05 wuwb 阅读(1178) 评论(0) 推荐(0)