[Python] Frequently used method or solutions for issues
Web Scraping爬虫 for Mac urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>
Solution: if 1) does not work, then try to use 2). Reference is here.
1)
pip install --upgrade certifi
2)
open /Applications/Python\ 3.6/Install\ Certificates.command
if running a python file to use https call, have error like
"SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661"
Solution:
then solve it by adding
configuration.verify_ssl = False
in the test file.
Then it will skip verifying SSL certificate when calling API from https server.
if running a python file to use https call, have the warning of InsecureRequestWarning
Solution:
then solve it by adding
import urllib3
urllib3.disable_warnings()
in the test file.
Then it will skip warning.
- Remove leading whitespace 去除string前面的空格
Solution:
>>> ' hello world!'.lstrip()
'hello world!'
Web Scraping爬虫看网页编码方式( 一般为“utf-8”)
Solution: F12功能键,即可使用开发者工具,在窗口console标签下,键入 "document.charset" 即可查看网页的编码方式
[Python] Frequently used method or solutions for issues的更多相关文章
- [JavaScript] Frequently used method or solutions for issues
Get the file name from the file path Solution: var fileName = fullPath.replace(/^.*[\\\/]/, ''); // ...
- [CSS] Frequently used method or solutions for issues
Stick button in right side in html Solution: //In the html <div class="float__button" & ...
- [Java] Frequently used method or solutions for issues
模板: Split string into parts based on new line in java Solution: Reference is here. 1) get out of t ...
- 关于Python的函数(Method)与方法(Function)
先上结论: 函数(function)是Python中一个可调用对象(callable), 方法(method)是一种特殊的函数. 一个可调用对象是方法和函数,和这个对象无关,仅和这个对象是否与类或实例 ...
- Python tricks(2) -- method默认参数和闭包closure
Python的method可以设置默认参数, 默认参数如果是可变的类型, 比如list, map等, 将会影响所有的该方法调用. 下面是一个简单的例子 def f(a=None, l=[]): if ...
- 2.Python函数/方法(method/function)详解
1.什么是函数 它是一段功能代码,理解为一种功能行为,在内存中有空间区域,函数需要被调用才能执行(通过函数名来调用): 好处: 1).提高代码的复用性 2).提升代码的阅读性 3).增加代码的扩展性 ...
- [Python] String strip() Method
Description The method strip() returns a copy of the string in which all chars have been stripped fr ...
- [Python] The get() method on Python dicts and its "default" arg
# The get() method on dicts # and its "default" argument name_for_userid = { 382: "Al ...
- Python String startswith() Method
一,摘自官方API https://docs.python.org/3/library/stdtypes.html#methods str.startswith(prefix[, start[, e ...
随机推荐
- HDU 1166 - 敌兵布阵 - [分块]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1166 题解: 本题作为一个模板题,我用它来检验过总查询时间复杂度为 $O(q \log n)$ 的树状 ...
- [No0000E8]C# 方法 参数传递
参数传递 当调用带有参数的方法时,您需要向方法传递参数.在 C# 中,有三种向方法传递参数的方式: 方式 描述 值参数 这种方式复制参数的实际值给函数的形式参数,实参和形参使用的是两个不同内存中的值. ...
- spark运行wordcount程序
首先提一下spark rdd的五大核心特性: 1.rdd由一系列的分片组成,比如说128m一片,类似于hadoop中的split2.每一个分区都有一个函数去迭代/运行/计算3.一系列的依赖,比如:rd ...
- MAC apache服务器搭建
一.启动原本服务器 首先打开“终端(terminal)”,输入 sudo apachectl -v,(可能需要输入机器秘密).如下显示Apache的版本: 可以输入启动命令进行启动: sudo apa ...
- io.UnsupportedOperation: not readable
两处错误一.你是用open打开一个文件,此时调用的是w写入模式,下面使用read是没有权限的,你得使用w+读写模式二.使用write写入一个字符s,但是此时并没有真正的写入,而是还存在与内存中.此时执 ...
- ubuntu物理机上搭建Kubernetes集群 -- 准备
准备工作 1.kubernetes架构 2.三台ubuntu主机: 操作系统:ubuntu-16.04.1-server-amd64 docker: 1.安装 使用命令 sudo apt-get in ...
- 主备归档不一致导致的RMAN-08137无法清理归档解决方案
值班夜里接到归档目录满的告警,执行删除脚本发现报错 RMAN-08137: WARNING: archived log not deleted, needed for standby or upstr ...
- ORACLE network environment
监听程序 建立网络连接 要建立客户机或中间层连接,Oracle Net要求客户机 下列事项: 运行监听程序的主机 监听程序监视的端口 监听程序使用的协议 监听程序处理的服务名 Hostname/ip ...
- SQL instr()函数的格式
格式一:instr( string1, string2 ) / instr(源字符串, 目标字符串) 格式二:instr( string1, string2 [, start_positio ...
- golang 死锁
golang中for{}会引起程序死锁 如: main(){ go func(){fmt.Println("dfkdsf")} for{ } } 程序运行一会会停止 按照下面的写法 ...