
Python
Thinkcortex
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 126: invalid continuation byte
python3在读文件时,用到了字符串处理方法, 所以将读出的内容转为strdecode()默认转为utf-8编码,但当文件包含其他编码格式内容时,可能就会出错。所以通过制定编码不是一个好的解决办法。可以: (1)l_bytes.decode("unicode_escape") (2)l_bytes.decode(encoding="utf-8", er...原创 2020-01-12 16:01:37 · 1974 阅读 · 0 评论 -
MySQLdb User's Guide
MySQLdb is an interface to the popular MySQL database server that provides the Python database API.https://mysqlclient.readthedocs.io/user_guide.html原创 2020-01-03 16:54:19 · 208 阅读 · 0 评论 -
ts文件解密+python脚本m3u8下载
通过m3u8下载视频文件, 下载完成后无法播放。查看m3u8文件,发现视频文件被加密,所以直接下载后不能直接播放。这里使用了AES-128加密,并且有IV, 所以是cbc模式。解密方法:(1) 下载key, 16字节数据。使用openssl即可。 以下是一个示例:openssl aes-128-cbc -d -in v.f30.ts -out fileSequence0_d...原创 2019-08-02 17:42:15 · 5969 阅读 · 7 评论 -
pyuv 实现 tcpping 问题记录
使用pyuv实现tcpping功能, 发现连接成功率偶尔会很低,但抓包发现实际的成功率要比探测结果高。程序流程: 创建pyuv.Timer, 进行周期连接以及判断超时。创建socket, 添加到pyuv.loop中,进行可写事件监听,connect。当出现一次连接超时后, 接下来的连接,都没有可写事件,无法进入回调函数,导致统计的成功次数低。(程序流程是当出现超时后,pyuv.watch...原创 2019-07-26 11:39:50 · 354 阅读 · 0 评论 -
psutil学习
1.net_if_addrs() Return the addresses associated to each NIC (network interface card) installed on the system as a dictionary whose keys are the NIC names and value is a list of namedtu...原创 2019-07-10 14:54:10 · 289 阅读 · 0 评论 -
pycurl invalid arguments to setopt
环境:python2.7在设置curl.setopt(pycurl.URL, url) 时抛出异常invalid argument to setopt原因是参数url 类型是unicode将其进行转换:v_url = v_url.encode('unicode-escape').decode('string_escape')...原创 2019-06-25 16:51:33 · 2208 阅读 · 0 评论 -
gdb调试python
gdb调试python coredump参考链接https://wiki.python.org/moin/DebuggingWithGdb环境: CentOS7.2 , python 2.7.5安装python-debuginfo。 直接yum安装不成功的话, 可参考上面的链接。 或者这里来这里下载https://buildlogs.centos.org/c7.00....原创 2019-05-27 14:13:48 · 1029 阅读 · 0 评论 -
Wing IDE使用
1. 选择背景 Edit--Preferences 个人比较喜欢黑色背景。2. 创建工程 Project -- New Project 选择python可执行程序, 也可以使用默认。 点击“OK”, 然后保存此工程到指定的位置。3. 添...原创 2019-04-28 10:20:41 · 1872 阅读 · 0 评论 -
python browsermob-proxy 问题
版本:browsermob-proxy 0.8.0使用: from browsermobproxy import ServerBROWSERMOBPROXY = "/usr/local/browsermob-proxy-2.1.4/bin/browsermob-proxy"server = Server( BROWSERMOBPROXY )......(其他代码省略)...原创 2018-12-21 15:09:02 · 8229 阅读 · 0 评论 -
python socket https请求及处理
import socketimport ssl def https_test(url): proto = "http" host = "" port = 80 up = urlparse(url) if (up.scheme != ""): proto = up.scheme print "proto=%s"%proto原创 2018-01-16 17:01:59 · 5424 阅读 · 0 评论 -
Python 异常错误记录
1. class_A instance has no attribute '__getitem__'出错原因:类中的函数参数没写self, 函数第一个参数为args, 取值时用v=args[0], 当类中的其他函数使用该函数是, 报错原创 2017-12-22 16:02:54 · 560 阅读 · 0 评论 -
python CRC32-mpeg2校验
之前在做STM32的IAP程序,为了提高可靠性,采用了CRC32校验。STM32有硬件CRC,采用的校验方式为CRC32-mpeg2。上位机是用python写的,在计算CRC校验值时,最初查到了binascii.crc32,但是发现它并不是CRC32-mpeg2。google了一下,找到了某位前辈写的代码。考虑到STM32采用的是小端模式,对此进行了处理。但是不能进行反复计算,所以又对程序进行原创 2016-07-04 12:35:47 · 2863 阅读 · 1 评论 -
python提示NameError: name 'xxx' is not defined
在使用Tkinter时,使用python自己的IDLE运行程序没问题,当使用命令提示符模式运行会出现错误NameError: name 'Tk' is not defined。错误出现在from tkinter import *top = Tk()问题的原因在于程序文件名为tkinter.py,当使用命令提示符运行时,工作路径切换到了tkinter.py所在路径,导入模块会首先查找当前路径。原创 2016-07-29 11:11:32 · 43669 阅读 · 0 评论 -
datetime.datetime() is not JSON serializable
python mysql json 报错: datetime.datetime(2017, 8, 28, 10, 24, 2) is not JSON serializableimport datetimeimport jsondef datetime_handler(x): if isinstance(x, datetime.datetime):原创 2017-08-28 13:54:45 · 2218 阅读 · 0 评论 -
windows下安装python MySQL
1. 安装mysql-installer-community-xxx.msihttps://dev.mysql.com/downloads/installer/2. 安装MySQLdb下载MySQL-python-1.2.3.win-amd64-py2.7.exe (根据系统及python版本选择),安装http://www.codegood.com/downloads原创 2017-08-15 11:13:47 · 824 阅读 · 0 评论 -
Python 学习
1. str list 互转def str_list(): s = "123abc" list_tmp = list(s) print (list_tmp) print (''.join(list_tmp)) print ('\n') s = "123,abc,456" list_tmp = s.split(",")原创 2017-07-14 09:53:29 · 344 阅读 · 0 评论