Python
shengda_mao1118
这个作者很懒,什么都没留下…
展开
-
【Linux】【MySQL】(Python连接)MySQLInterfaceError: Host 'xx.xx.xx.xx' is not allowed to connect
最近在用python-django写一个注册比赛,比赛报名,查询报名人员信息的一个app。在数据库连接的时候遇到这个error.本质是 root 用户只授权了 root@localhost ,而 root@<other IP host> 没有权限访问 MySQL.(服务器的防火墙3306都配置无误,netstat -tnlp 里mysql service也在监听 330...原创 2020-01-05 22:01:44 · 281 阅读 · 0 评论 -
【Python】【MySQL】_实战_python使用mysql.connector
MySQL官方文档:https://dev.mysql.com/doc/MySQL.Connector / Python 文档:https://dev.mysql.com/doc/connector-python/en/最新版本:Connector/Python 8.0.16PyCharm的截图,可以根据该名称搜索三方库。import mysql.connectorcn...原创 2019-05-06 16:15:23 · 465 阅读 · 0 评论 -
【Python】【Pyinstaller】pyinstaller相关参数
-F, –onefile 打包一个单个文件,如果你的代码都写在一个.py文件的话,可以用这个,如果是多个.py文件就别用-D, –onedir 打包多个文件,在dist中生成很多依赖文件,适合以框架形式编写工具代码,我个人比较推荐这样,代码易于维护-K, –tk 在部署时包含 TCL/TK-a, –ascii 不包含编码.在支持Unicode的python版本上...原创 2019-02-24 09:43:12 · 167 阅读 · 0 评论 -
【Python】【Pyinstaller】【Pyside2】pyinstaller 与 multiprocessing库冲突
场景交待:用 PySide2 写了一个GUI, 先调用了 multiprocessing.process() ,再新建 QThread类。GUI制作完成,打包前正常使用,打包后涉及 multiprocessing的功能全部崩溃。一开是定位是 Pyside2 导致,换了 Pyside1, QtPy5, QtPy4 都未解决问题。最后一遍一遍地读 错误日志时,发现每次都有一段写 mult...原创 2019-08-19 10:17:22 · 867 阅读 · 0 评论 -
【Python】【PySide2】多进程的实现 QProcess模块,打开外部程序,传入命令行参数
在使用 Qt For Python 编写GUI时遇到个问题,GUI界面有一个主进程,在不使用QProcess, QThread情况下,都是默认单线程与单进程的。例如新建一个按钮,该按钮调用一个槽函数 是 time.sleep( 10000) ,那在这个槽函数运行完之前,整个UI界面都是假死状态(无响应),要等整个槽函数运行完后才能GUI恢复控制。所以在有一个槽函数需要消耗很多时间的情况下,必须...原创 2019-07-31 17:47:38 · 3562 阅读 · 4 评论 -
【Python】【.pcap】 python 读取 pcap内容
http://blog.sina.com.cn/s/blog_4b5039210100gnlu.html想试一试读取pcap文件的内容,并且分析出pcap文件头,每一包数据的pcap头,每一包的数据内容(暂时不包括数据包的协议解析),关于pcap文件的格式,可以参看:http://blog.sina.com.cn/s/blog_4b5039210100fzrt.html搞了一下午...转载 2019-03-04 10:43:30 · 2039 阅读 · 0 评论 -
【python】中按原码取反_按位取反
在python中,取反操作是按补码进行的,而在C/C++是按原码来取反。原创 2019-07-23 10:45:32 · 1262 阅读 · 0 评论 -
【Python】 sort() 函数详解
alist.sort( key = None, reverse = false)关于第一个参数的作用。例1:def compare (x) : return len(x)alist.sort( key = compare)这时,alist会根据compare函数的结果进行排序,但排序前后,不会改变alist中元素的值。例2:def absSort (x):...原创 2019-01-18 21:49:16 · 355 阅读 · 0 评论 -
【Python】列表推导式
例一:multiples = [i for i in range(30) if i % 3 is 0]print(multiples)# Output: [0, 3, 6, 9, 12, 15, 18, 21, 24, 27]例二:def squared(x): return x*xmultiples = [squared(i) for i in rang...原创 2019-04-03 15:39:08 · 155 阅读 · 0 评论 -
【python】文档___Assert关键字
The assert statementAssert statements are a convenient way to insert debugging assertions into a program:assert_stmt ::= "assert"asser_stmt ::= "assert" expression [“,"expression]The simple f...原创 2019-04-04 10:50:00 · 142 阅读 · 0 评论 -
【Python】 format格式化输出
n = 100print(n)print('{0}'.format(n))print('{0:>20}'.format(n))print( '{0:->20}' .format(n))输出结果:100100 100-----------------100...原创 2019-02-15 16:10:56 · 1613 阅读 · 0 评论 -
【Python】print的格式化输出的2种方法。
简略得分2种。分2个函数重载,至于第一种方法中,%相关的格式化输出,网上太多了自己搜吧。a = "50"b = "100"print("a = %s, b = %s" %(a, b) )print("{0} is a good {1} ".format("Jack", "student") )a = 50, b = 100Jack is a good student...原创 2019-02-15 14:14:05 · 645 阅读 · 0 评论