
python
Aodongq1n丶
坐标:深圳
职业:从事云计算和互联网金融相关工作
WX:qpz2235440785
展开
-
centos安装python3
安装编译环境sudo yum -y groupinstall "Development tools"sudo yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel下载python安装包wget https://www.pytho原创 2021-03-02 23:55:25 · 599 阅读 · 0 评论 -
[python]为什么在sys.setdefaultencoding之前要写reload(sys)
原因这是因为python模块的加载过程中首先加载了site.py,在site.py文件中有这么一段代码if hasattr(sys,"setdefaultencoding"): del sys.setdefaultencoding所以在sys加载后,setdefaultencoding方法被删除了,所以需要reload(sys)来重新导入sys,来设置编码- 如何不使用上述方式,如何改变默认编码在python安装目录下的lib下的site-packages 目录中,新建文件site.原创 2020-10-07 20:36:26 · 358 阅读 · 0 评论 -
[python]字符编码详解
https://www.cnblogs.com/luodaoqi/p/11323828.html转载 2020-10-07 20:08:26 · 103 阅读 · 0 评论 -
[python]__file__的一个小坑
作用输出当前执行文件的文件名坑点如果执行文件是以相对路径的形式执行,那么__file__只能返回文件名。如果执行文件是以绝对路径的形式执行,那么__file__返回绝对路径的文件名。python config_helper.py ---> config_helper.pypython /data/server/config_helper.py ---> /data/server/config_helper.py...原创 2020-10-07 19:30:54 · 178 阅读 · 0 评论 -
[python] isinstance与type
type() 不会认为子类是一种父类类型,不考虑继承关系isinstance() 会认为子类是一种父类类型,考虑继承关系>>>a = 2>>> isinstance (a,int)True>>> isinstance (a,str)False>>> isinstance (a,(str,int,list)) # 是元组中的一个返回 TrueTrueclass A: pass clas..原创 2020-10-07 15:44:08 · 181 阅读 · 0 评论 -
win10下如何配置pip
pippip配置文件 以win10为例,其他的没试过 win+r ,%APPDATA% 如果没有pip目录,新建pip目录 新建pip.ini 输入如下内容: [global]time-out=60index-url=https://pypi.tuna.tsinghua.deu.cn/simple/[install]trusted-host=tsinghua.edu.cn 命令行pip进行安装 ...原创 2020-10-07 15:37:49 · 294 阅读 · 0 评论 -
[python] requirements.txt
requirements.txt类似ruby的gemfile生成requirements.txtpip freeze > requirements.txt安装requirements.txt依赖pip install -r requirements.txt原创 2020-10-07 15:32:46 · 102 阅读 · 0 评论 -
os.path的几个进阶用法
os.pathos.path.expanduser() 作用:替换路径中的~ 用法 >>>os.path.expanduser("~/Build")'/usr/testuser/Build'>>>os.path.exists(os.path.expanduser("~/Build"))True os.path.expandvars() 作用:替换路径中的$NAME或者${NAME} 用法 >>&.原创 2020-10-07 15:28:15 · 926 阅读 · 0 评论 -
#! /usr/bin/python 到底有什么用
一般python脚本的第一行,都会有这么一个东西。以前写python,都不知道这个东西有什么用。。。所以最近研究了一下,发现还是有用处的。写法首先这个东西叫“shebang”。不知道为什么叫这个名字:)这句话的正确写法是#! /usr/bin/python。错误写法# !/usr/bin/python。正确与错误的区别就在于#!之间是否有空格。没有空格就是正确的。有空格就是错误的。错误情...原创 2020-04-30 01:12:10 · 1101 阅读 · 0 评论 -
urllib2.urlopen 手工调用没问题,通过crontab调用报错 [Errno 110] Connection timed out
背景:准备实现一个脚本,用来监控进程是否还存在,如果不存在,通过调用企业微信机器人回调地址来通知群内的人员问题现场:手工调用,python notify.py 可以正确通知。但是将脚本加入crontab,每分钟执行一次时,脚本有执行,但是无法通知群内用户。通过日志定位,报错信息为“<urlopen error [Errno 110] Connection timed ou...原创 2020-03-12 16:26:55 · 2300 阅读 · 0 评论 -
windows计划任务执行如何静默执行python程序
前言如何添加windows计划任务这里就不说了,很多博文也有讲到,baidu,google一下很多的。大家可以自己搜一搜这里主要讲2个问题:1. 如何静默执行python程序?很多windows平台下的python程序一执行,就会弹出dos窗口2.明明添加了可执行程序,但是无法执行。windows计划任务执行程序,也不会主动给你弹错误出来。怎么定位呢?解答1. 如何静默执行...原创 2020-02-10 23:19:01 · 3326 阅读 · 1 评论 -
用python实现一个端口扫描器
端口扫描的概念端口扫描工具(Port Scanner)指用于探测服务器或主机开放端口情况的工具。常被计算机管理员用于确认安全策略,同时被攻击者用于识别目标主机上的可运作的网络服务。 端口扫描定义是客户端向一定范围的服务器端口发送对应请求,以此确认可使用的端口。虽然其本身并不是恶意的网络活动,但也是网络攻击者探测目标主机服务,以利用该服务的已知漏洞的重要手段。端口扫描的主要用途仍然只是确原创 2018-01-06 00:10:57 · 617 阅读 · 0 评论