R:当使用urllib.urlopen打开一个 https 链接时,会验证一次 SSL 证书。
A:针对urllib.urlopen,增加参数context=context
import ssl
context = ssl._create_unverified_context()
webPage = urllib.request.urlopen(req,context=context)针对 requests.get/post,增加参数verify=False
response_result = requests.get(url,data,verify=False)R:请求的header中含有'Accept-Encoding': 'gzip, deflate',这句话的意思是本地接收压缩格式的数据,浏览器能够自动解压,程序却不能自动解压。
A:删掉 header 中的 Accept-Encoding
A:to_csv()中添加参数 _encoding='utf_8_sig'
A:通过pd.set_option('display.max_rows', None)设置pandas显示的最大行数,None 为不限制
R:wordcloud默认是不支持中文的
A:通过font_path给wordcloud指定一种支持中文的字体文件
wordcloud = WordCloud(font_path='resources/msyh.ttf')R:png格式图片作为底图是不能被识别的,即使强行把图片后缀改为jpg也不行
A:(最好)找jpg格式的图片作为底图
A:需要安装一个xcode的命令行工具,链接:https://developer.apple.com/download/more/?name=for%20Xcode,如果还不行的话,再安装一下xcode。
A:创建 Page 对象,将每个 Line 添加到 Page 中来显示。
page = pyecharts.Page()
line = pyecharts.Line("多折线图")
for item in df1.columns:
line.add(item,df1.index.tolist(),df1[item].tolist(),is_datazoom_show=True)
page.add(line)R:汉字被进行了16进制编码
A:respose.content.decode('utf-8')
A:
- 下载flask_cors包:
pip3 install flask-cors - 使用flask_cors的CORS,代码示例:
from flask_cors import *
app = Flask(__name__)
CORS(app, supports_credentials=True)import lxml.html
etree = lxml.html.etree