随笔 - 911  文章 - 5  评论 - 94  阅读 - 243万

随笔分类 -  Python

上一页 1 2 3 4 5 6 下一页
修改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 阅读(3131) 评论(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 阅读(3695) 评论(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 阅读(6965) 评论(0) 推荐(0) 编辑
编译.py为.pyc
摘要:将test.py编译为.pyc文件,然后直接使用.pyc即可,防止源码外泄 阅读全文
posted @ 2019-03-11 11:01 momingliu11 阅读(1576) 评论(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 阅读(367) 评论(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 阅读(20509) 评论(0) 推荐(2) 编辑
字典Key值为变量
摘要:m='aaa4a' d = dict(name=m) print d['name'] 阅读全文
posted @ 2018-03-16 18:39 momingliu11 阅读(1088) 评论(0) 推荐(0) 编辑
IP地址查询
摘要:设置URL超时: 调用新浪IP查询接口: Python3: 阅读全文
posted @ 2016-11-05 11:53 momingliu11 阅读(1044) 评论(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 阅读(1379) 评论(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 阅读(17664) 评论(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 阅读(994) 评论(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 阅读(595) 评论(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 阅读(6608) 评论(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 阅读(401) 评论(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 阅读(484) 评论(0) 推荐(0) 编辑
检查远端服务器端口是否打开
摘要:import socket def TelnetPort(server_ip,port): sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sk.settimeout(1) #设置超时时间 try: sk.connect((server_ip,port)) print 'OK!' ... 阅读全文
posted @ 2016-07-12 17:12 momingliu11 阅读(751) 评论(0) 推荐(0) 编辑
将目录结构输出为json格式(zTree)
摘要:实例:将目录转换为zTree使用的json字符串格式 返回值:: {"nocheck": true, "type": "directory", "name": "BACKUP", "children": [{"nocheck": true, "type": "directory", "name": 阅读全文
posted @ 2016-06-22 16:58 momingliu11 阅读(1591) 评论(0) 推荐(0) 编辑
python执行sql语句
摘要:dbname = 'db.sqlite3' dbpath = 'D:\\pyweb\\sf\\db.sqlite3' csvpath = pspath #custom thread number tnum = 20 hvsrvs_all =hvsrvs.objects.all() serverips=[] #ls = [] ... 阅读全文
posted @ 2016-06-21 17:59 momingliu11 阅读(19313) 评论(0) 推荐(0) 编辑
IP解析计算机名称
摘要:#-*- coding: UTF-8 -*- import subprocess,sys,threading reload(sys) sys.setdefaultencoding('utf-8') def ip2name(mutex,ip,fp,kw): nbtstatchild = subprocess.Popen(['nbtstat','-A',ip],shell=True,s... 阅读全文
posted @ 2016-06-13 16:07 momingliu11 阅读(511) 评论(0) 推荐(0) 编辑
Python脚本性能分析
摘要:来自:http://www.cnblogs.com/btchenguang/archive/2012/02/03/2337112.html 运行:python -m cProfile t12.py,打印结果: 其中,输出每列的具体解释如下:(http://xianglong.me/article/a 阅读全文
posted @ 2016-05-31 11:37 momingliu11 阅读(992) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 下一页
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示