随笔分类 -  Python

上一页 1 2 3 4 5 6 下一页
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 阅读(751) 评论(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 阅读(1315) 评论(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 阅读(6226) 评论(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 阅读(377) 评论(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 阅读(1259) 评论(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 阅读(3161) 评论(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 阅读(3699) 评论(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 阅读(6991) 评论(0) 推荐(0)
编译.py为.pyc
摘要:将test.py编译为.pyc文件,然后直接使用.pyc即可,防止源码外泄 阅读全文
posted @ 2019-03-11 11:01 momingliu11 阅读(1583) 评论(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 阅读(375) 评论(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 阅读(20526) 评论(0) 推荐(2)
字典Key值为变量
摘要:m='aaa4a' d = dict(name=m) print d['name'] 阅读全文
posted @ 2018-03-16 18:39 momingliu11 阅读(1100) 评论(0) 推荐(0)
IP地址查询
摘要:设置URL超时: 调用新浪IP查询接口: Python3: 阅读全文
posted @ 2016-11-05 11:53 momingliu11 阅读(1053) 评论(0) 推荐(0)
Python LDAP中的时间戳转换为Linux下时间
摘要:(Get-ADUser zhangsan -Properties badpasswordtime).badpasswordtime返回值为:131172610187388712131172610187388712为长整型时间戳(18位),精确到了纳秒级别。该时间戳是从1601-01-01 8:00: 阅读全文
posted @ 2016-09-02 13:03 momingliu11 阅读(1421) 评论(0) 推荐(0)
LDAP查询过滤语法(MS)
摘要:http://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx?Sort=MostUseful LDAP Clauses A filter specif 阅读全文
posted @ 2016-09-02 11:10 momingliu11 阅读(17932) 评论(0) 推荐(1)
从外部导入django模块
摘要:import os import sys sys.path.append("D:\\pyweb\\sf"); # 项目位置(不是app) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sf.settings")import djangodjango.setup() #如果不加上这两句,delete会报错,提示Models aren't ... 阅读全文
posted @ 2016-08-31 16:17 momingliu11 阅读(1000) 评论(0) 推荐(0)
Python发送邮件
摘要:Python3.9发邮件,587端口 import smtplib,ssl from email.mime.text import MIMEText from email.header import Header # context = ssl.create_default_context() co 阅读全文
posted @ 2016-08-29 14:30 momingliu11 阅读(603) 评论(0) 推荐(0)
通过ajax GET方式查询数据,Django序列化objects
摘要:点击“查找2”按钮,通过ajax GET方式进行查询数据,这样页面不需要整体刷新,之后清空tbody数据,将查询结果重新附加到tbody 前端html: 前端js: 编写view(Django序列化objects): print srvs_json [{"fields": {"OSVersion": 阅读全文
posted @ 2016-08-25 10:53 momingliu11 阅读(6629) 评论(0) 推荐(1)
倒序输出
摘要:ll= [1,2,3,4,5]print ll[::-1] ll.reverse() for l in reversed(ll): print l 倒序读取文件: 阅读全文
posted @ 2016-08-11 17:05 momingliu11 阅读(412) 评论(0) 推荐(0)
pycrypto加解密
摘要:下载pycrypto:http://www.voidspace.org.uk/python/modules.shtml#pycrypto (Windows版本) From:http://www.cnblogs.com/kaituorensheng/p/4501128.html 阅读全文
posted @ 2016-08-04 15:48 momingliu11 阅读(492) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 下一页