[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 ...
随机推荐
- Linux 磁盘管理命令
df NO1. 显示所有存储系统空间使用情况,同时显示存储系统的文件系统类型s[root@rehat root]# df -aT NO2. 显示指定文件系统的空间使用情况[root@rehat roo ...
- mysql 登录远程数据库
mysql -h${hostIP} -P${hostPort} -u${userName} -p${passwd}
- Win 10 计算机管理失效(Windows找不到文件“C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools\Computer Management.lnk)
Windows找不到文件“C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools\Computer Mana ...
- EXSI中Linux安装tools
挂载 mount /dev/cdrom /mnt/ 进入挂载目录复制安装包 cp VMwareTools-10.2.1-8267844.tar.gz /tmp/ 解压安装 cd /tmp/ tar - ...
- CH 1602 - The XOR Largest Pair - [字典树变形]
题目链接:传送门 描述在给定的 $N$ 个整数 $A_1, A_2,\cdots,A_N$ 中选出两个进行xor运算,得到的结果最大是多少? 输入格式第一行一个整数 $N$,第二行 $N$ 个整数 $ ...
- vuex 的基本使用之Module
Module 首先介绍下基本的组件化规则:你可以根据项目组件的划分来拆分 store,每个模块里管理着当前组件的状态以及行为,最后将这些模块在根 store 进行组合. const moduleA = ...
- php之memcached存储session配置、存储、获取
[session] ①.session.save_handler = memcache session.save_handler 定义了来存储和获取与会话关联的数据的处理器的名字,默认是files ② ...
- jquery基础学习之动画篇(四)
一,动画效果 hide() show() 隐藏与显示 hide(options) 隐藏 对应display:none,有参数就会变成动画, $(document).click(function () ...
- El表达式对照表
设置 session.getAttribute("date" "date") 取得username的值 (String)session.getValue( ...
- java之获取资源文件
背景介绍 在java程序中有时我们需要加载项目中的某些资源文件(如:config.properties之类),以便获取里面的值,这样可以避免某些需要经常修改的数据硬编码入业务程序中 实现方式 实现这种 ...