python3.5相关内容
问 题 IDE默认用得是utf-8编码的 而爬取的网页是gb2312的 然后就出错了 UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte html = response.decode('utf-8') # 我是把网页的内容decode成utf-8之后再
..
#-*- coding:utf-8 -*- import requests as req from time import time def return_url(roomid): roomid = str(roomid) ts = str(int(time()*1000)) url = "http://www.panda.tv/api_room?roomid={0}&
..
使用python3.5执行sql语句(update)完成后,返回正确的影响行数 然后在使用pymysql获取刚刚update的数据,返回的数据也是修改过的 但是 我又使用sqlyog去看刚才修改的记录 发现根本没变 具体如下: mysql类: class MysqlClass: def __init__(self, host, user, passwd, dbN
..
1.tableWidget怎么控制大小,能否用label来替代? 2.如何添加动作,点击目录后导出内容? 3.通过setColumnStretch设置的列宽,在目录导出后,约束失效了,这是为什么? import sys from PyQt5.QtWidgets import * import urllib.request as request import Spider class M
..
对数据分析时使用到pandas,下面的代码是从数据库中获取数据再转换成DataFrame结构 sql = 'select * from content;' cur.execute(sql) rows = cur.fetchall() datas = [] for data in rows: datas.append(data) frame = DataFrame(datas) 数
..
首先我安装了Anaconda,一切正常,基本功能都可以调用 我的版本是:Python 3.5.2 |Anaconda 4.1.1 (64-bit) 但是 我开始调用 notebook时,出现如下问题 于是乎,我又按照提示 利用%pylab inline 或者 %matplotlib inline 再然后我利用ipython 运行 %pylab inline 和 %matplotli
..
初学pyspider 环境为windows7 64位;python3.5.2 64位;anaconda3 4.1.1 64位 phantomjs-2.1.1部署在 C:Anaconda3Scripts目录下 使用wheel lxml-3.6.1-cp35-cp35m-win_amd64.whl 安装lxml 使用 pip install pyspider 顺利安装pyspider cm
..
问 题 有一个列表.里面有不确定的字符,直接print会报错,源码如下 #coding=utf8 import itchat, time import sys from itchat.content import * @itchat.msg_register([TEXT, MAP, CARD, NOTE, SHARING]) def text_reply(msg): prin
..
新入门做的一个爬取文段程序,代码看起来比较臃肿,请问有没有什么好的建议呢? 另外我准备在for循环末尾把数据插入mysql数据库,这样做好吗,还是说再弄一个for循环,第一个for循环把数据存进二维列表里,第二个循环再逐条插入数据呢? #-*- coding:utf-8 -*- import re from pyquery import PyQuery as pq import tim
..
问 题 main.py layout_format = {} for filename in os.listdir('mod'): if filename.endswith('py'): for line in open(os.path.join('mod',filename)): eval(line) print(layout_for
..
问 题 譬如说输出warning是黄色的,info是蓝色的,error是蓝色的,这样的模块? 解决方案 在终端下面, 色彩转换是通过控制字符来实现的, 你可以参考 http://stackoverflow.com/ques... 里面还有终端下所有色彩的代码表 或者直接用 https://pypi.python.org/pypi/... 如果你要实现log
..
问 题 main.py import os import time from zhihu_oauth import ZhihuClient import html2text _h = html2text.HTML2Text() layout_format = {} for filename in os.listdir('mod'): if filename.endswit
..
问 题 如果我写了一个包开源到github上(水平渣不敢放到pip),我该如何处理包依赖问题? 就是我写的包依赖第三方包,如果我直接把代码发到github,别人下载肯定不能用 难道只能写在readme.md中? 或者是requirements.txt?使用者把requirements.txt复制粘贴到自己项目中的requirements.txt? 希望举个例子说明:如
..
问 题 import os import re import urllib.parse import urllib.request import threadpool def download_file(url): print("Begin download {}".format(url)) urlhandler = urllib.request.urlopen(url)
..
问 题 python3.5.2版本安装时make步骤报错,报错信息如下: /bin/mkdir -p Python python ./Parser/asdl_c.py -c Python ./Parser/Python.asdl Traceback (most recent call last): File "./Parser/asdl_c.py", line 6, in
..
问 题 此前一直是做PHP开发的,现在想学习下爬虫开发,很疑惑呀不知道从何做起,请大家指教下学习线路,我是属于想要深入研究型的。网上看到很多示例感觉就像做采集,Url扩散爬去和分析部分的资料很少...求推荐学习线路、数据、视频等各种,能介绍下避坑攻略就更好啦。 解决方案 做过web开发的我觉得做爬虫很简单,明确这个是http协议就ok了 随便说几点吧 爬取速度(控制与
..
首先需要配置环境,创建win32控制台程序,然后对工程进行配置。 项目–>属性–>vc++目录–>包含目录 添加python安装目录中include目录 项目–>属性–>vc++目录–>库目录 添加python安装目录中libs目录 链接器–>输入–>附加依赖项 添加python36.lib 注意,如果C++工程采用debug版本,需要将将 python安装目录里libs文件夹下的py
..
问 题 如何将 python3.4 的程序转为 python2.7,不是 python2.7 转 python3 解决方案 Python 3 转成Python 2,安装 3to2 安装: pip install 3to2, 运行: 3to2 file.py, 具体怎么用 看3to2 --help
..
我使用的Python版本为3.5.2,尝试用zipfile模块的zipfile.ZipFile.open方法打开一个压缩包中的文本文件时,即使使用了文档中要求的rU参数,打开时仍然是以二进制数据格式打开的,百思不得其解。 代码: >>> import zipfile >>> zf = zipfile.ZipFile('/Users/chiqingjun/Downloads/top-1m
..
环境: windows 10 python 3.5.3 各包的版本 $ pip list appdirs (1.4.3) cycler (0.10.0) matplotlib (2.0.2) numpy (1.13.0+mkl) olefile (0.44) packaging (16.8) Pillow (4.1.1) pip (9.0.1) protobuf (3.3.
..