随笔分类 -  Python

1 2 3 4 5 下一页
Python发送企业微信消息
摘要:给某个用户发送文本消息 #! /usr/bin/env python # -*- coding: UTF-8 -*- import requests, sys class SendWeiXinWork(): def __init__(self): self.CORP_ID = "ww2w" # 企业 阅读全文
posted @ 2024-04-13 00:14 momingliu11 阅读(1) 评论(0) 推荐(0) 编辑
Python3.6升级到3.9
摘要:1.升级openssl到1.1.1n cd /data/softwares cd openssl-1.1.1n ./config make && make install ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1 ln 阅读全文
posted @ 2023-08-24 17:40 momingliu11 阅读(383) 评论(0) 推荐(0) 编辑
pip安装whl制定下载源
摘要:pip3 install click_house -i https://pypi.tuna.tsinghua.edu.cn/simple/ 阅读全文
posted @ 2023-08-03 15:07 momingliu11 阅读(18) 评论(0) 推荐(0) 编辑
Python3通过cookie登录
摘要:import json,urllib.request,urllib.parse,http.cookiejar url_base = 'https://spam.forti.com/api/v1' url_admin = 'AdminLogin' data = {'name' : 'admin', ' 阅读全文
posted @ 2022-03-09 17:25 momingliu11 阅读(449) 评论(0) 推荐(0) 编辑
Python2.7升级pip失败解决办法
摘要:CentOS下通过 pip install --upgrade pip 升级pip版本失败,解决方法如下: Python2.7自带pip版本为8.1, pip install --upgrade pip总是报错 wget wget https://bootstrap.pypa.io/get-pip. 阅读全文
posted @ 2021-12-29 14:22 momingliu11 阅读(600) 评论(0) 推荐(0) 编辑
Python3 Post Get API
摘要:import sys,urllib.request,urllib.parse,json,string class GetDeviceDataAPI(): def __init__(self,name,password): #定义主url、获取token的url,获取设备信息的url self.url 阅读全文
posted @ 2021-12-05 00:35 momingliu11 阅读(129) 评论(0) 推荐(0) 编辑
pip指定安装源
摘要:pip3 install exchangelib -i https://pypi.tuna.tsinghua.edu.cn/simple 安装指定的包,并指定安装源 RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.e 阅读全文
posted @ 2021-09-21 16:34 momingliu11 阅读(617) 评论(0) 推荐(0) 编辑
Python调用Jenkins接口批准/拒绝Pipeline流程
摘要:import jenkins,requests,urllib jenkins_server_url = 'http://jenkins.jk.com/' user_id = 'approver' api_token = '1187e29' # api_token = 'password' job_n 阅读全文
posted @ 2020-11-10 11:11 momingliu11 阅读(682) 评论(0) 推荐(0) 编辑
Python对json排序分组
摘要:res_dl是一个json字符串,如下: [{'time': '2020/8/10 12:37:29', 'url': 'http://www.baidu.com/Account/QrCodeLoginPost?returnUrl=127.0.0.1', 'ip': '120.229.137.87' 阅读全文
posted @ 2020-08-12 18:33 momingliu11 阅读(1248) 评论(0) 推荐(0) 编辑
Python3下urllib.parse.urlencode()编码
摘要:zabbix_url="http://10.10.2.2/zabbix/api_jsonrpc.php"headers = {'Content-Type':'application/json'}auth_data = { "jsonrpc":"2.0", "method":"user.login", 阅读全文
posted @ 2020-05-27 11:46 momingliu11 阅读(6135) 评论(1) 推荐(0) 编辑
Python2调用Salt API
摘要:#!/usr/bin/env python #coding=utf-8 #For Python2 import urllib,urllib2,json,sys,importlib,argparse reload(sys) sys.setdefaultencoding('utf-8') class s 阅读全文
posted @ 2020-05-25 16:32 momingliu11 阅读(365) 评论(0) 推荐(0) 编辑
Python3调用Salt API
摘要:curl调用salt api cmd.run使用方法如下: curl http://10.10.2.11:8000 \ -H 'Accept: application/x-yaml' \ -H 'X-Auth-Token: 042a226e6'\ -d client=local \ -d tgt=' 阅读全文
posted @ 2020-05-20 18:15 momingliu11 阅读(1170) 评论(0) 推荐(0) 编辑
修改json文件
摘要:import os,json f = 'D:\\temp\\userlist.json' f2 = 'D:\\temp\\userlist2.json' file = open(f,'rb') fj = json.load(file) file.close() fj['liu'].remove('liu.ad3') fj['liu'].append('liu.ad4') # print... 阅读全文
posted @ 2019-12-11 18:16 momingliu11 阅读(3108) 评论(0) 推荐(0) 编辑
Python对csv排序
摘要:#/usr/bin/evn python # -*- coding: utf-8 -*- import sys from operator import itemgetter # input_file = open(sys.argv[1]) input_file = open("D:\\tmp\\a.csv") output_file = open("D:\\tmp\\asorted.csv"," 阅读全文
posted @ 2019-11-15 17:01 momingliu11 阅读(3684) 评论(0) 推荐(0) 编辑
ElasticSearch查看删除关闭索引
摘要:curl -XDELETE 'http://10.1.2.2:9200/iis_log_2019-07' #删除名为/iis_log_2019-07的索引 curl -XPOST 'http://10.1.2.2:9200/iis_log_2019-07/_close/' #关闭名为/iis_log 阅读全文
posted @ 2019-07-17 18:09 momingliu11 阅读(6902) 评论(0) 推荐(0) 编辑
编译.py为.pyc
摘要:将test.py编译为.pyc文件,然后直接使用.pyc即可,防止源码外泄 阅读全文
posted @ 2019-03-11 11:01 momingliu11 阅读(1565) 评论(0) 推荐(0) 编辑
Python操作Mysql
摘要:来源:http://www.runoob.com/python3/python3-mysql.html 安装PyMySql pip3 install PyMySQL 连接Testdb数据库: #!/usr/bin/python3 import pymysql # 打开数据库连接 db = pymys 阅读全文
posted @ 2018-07-13 16:17 momingliu11 阅读(363) 评论(0) 推荐(0) 编辑
python之bytes和string
摘要:转自:https://www.cnblogs.com/skiler/p/6687337.html 1、bytes主要是给在计算机看的,string主要是给人看的 2、中间有个桥梁就是编码规则,现在大趋势是utf8 3、bytes对象是二进制,很容易转换成16进制,例如\x64 4、string就是我 阅读全文
posted @ 2018-07-13 16:08 momingliu11 阅读(20498) 评论(0) 推荐(2) 编辑
字典Key值为变量
摘要:m='aaa4a' d = dict(name=m) print d['name'] 阅读全文
posted @ 2018-03-16 18:39 momingliu11 阅读(1082) 评论(0) 推荐(0) 编辑

1 2 3 4 5 下一页