Django站点使用django_cas接入SSO(单点登录系统),配置完成后登录,抛出“urlopen error unknown url type: https”异常.寻根朔源发现是python内置的urllib模块不支持https协议. >>> import urllib>>> urllib.urlopen('http://www.baidu.com')<addinfourl at 269231456 whose fp = <socket._fileo…
Python内置的操作系统模块(os)与解释器交互模块(sys) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 本片博客只介绍Python调用操作系统的模块即os模块,以及Python和解释器打交道的模块即sys模块. 一.操作系统模块常用方法(os) #!/usr/bin/env python #_*_coding:utf-8_*_ #@author :yinzhengjie #blog:http://www.cnblogs.com/yinzhengjie/tag/pyth…
urllib库 urllib库是Python中一个最基本的网络请求的库.它可以模拟浏览器的行为发送请求(都是这样),从而获取返回的数据 urllib.request 在Python3的urllib库当中,所有和网络请求相关的方法都被集成到了urllib.request模块下 #基本使用 from urllib import request resp = request.urlopen("URL") print(resp.read()) 如果是成功的,那么我们打印的内容和在浏览器中右击查…
1.内置函数(无需导入)long() 函数将数字或字符串转换为一个长整型.len() 统计元素个数print() 打印,输出input() 输入,或阻塞程序运行type 获取类型range 产生连续的整数对象enumerate 枚举可迭代对象ord 字符转ASCIIchr ASCII转字符abs 求绝对值 类型转换 int float str bool list tup set dict max() 最大值min() 最小值sum 求和pow 求幂round 四舍五入 hex 十六进制oct 八…
timeit模块 timeit模块可以用来测试一小段Python代码的执行速度. class timeit.Timer(stmt='pass', setup='pass', timer=<timer function>) Timer是测量小段代码执行速度的类. stmt参数是要测试的代码语句(statement): setup参数是运行代码时需要的设置: timer参数是一个定时器函数,与平台有关. timeit.Timer.timeit(number=1000000) Timer类中测试语句…
logging模块: 默认情况下,logging将日志打印到屏幕,日志级别为WARNING:日志级别大小关系为:CRITICAL > ERROR > WARNING > INFO > DEBUG > NOTSET,当然也可以自己定义日志级别. 配置logging对日志的输出格式: import logginglogging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(filename)s[line:%(line…
默认情况下ssl模块并未被安装,如果要使用该模块则需要在编译nginx时指定–with-http_ssl_module参数. 需求:做一个网站域名为 www.localhost.cn 要求通过https://www.localhost.cn进行访问. 10.10.100.8 www.localhost.cn实验步骤: 1.首先确保机器上安装了openssl和openssl-devel 1 2 #yum install openssl #yum install openssl-devel 2.创建…
if(/Android [4-6]/.test(navigator.appVersion)) { window.addEventListener("resize", function() { if(document.activeElement.tagName=="INPUT" || document.activeElement.tagName=="TEXTAREA") { window.setTimeout(function() { docume…
错误提示 com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client 错误原因 Mysql8 之前的版本中加密规则是mysql_native_password,而在Mysql8之后,加密规则是caching_sha2_passwo…
day15 内置函数和模块 1.三元表达式 代码如下: x = 1 y = 2 res = 'ok' if x > y else 'no' print(res) 输出结果:no 2.内置函数:重点 需要掌握的: int float str list tuple dict set bool bytes s = frozenset({1,2,3}) # 不可变集合 print(type(s)) 3.面向对象 需要掌握的: object classmethod staticmethod propert…