
python
ciyuacca
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python 操作execl 格式设置
import xlwt;from datetime import datetime,timedelta;def date_compare(date1, date2, fmt='%Y-%m-%d') -> bool: """ 比较两个真实日期之间的大小,date1 > date2 则返回True :param date1: :param date2: :param fmt: :return: """ zero = datet.原创 2021-04-13 11:25:56 · 204 阅读 · 0 评论 -
python mail 脚本
#!/usr/bin/python# -*- coding: UTF-8 -*-import smtplibfrom email.mime.text import MIMETextfrom email.utils import formataddrfrom email.mime.text import MIMETextfrom email.mime.multipart import MIMEMultipartfrom email.header import Headermy_sende.原创 2021-04-07 17:55:53 · 206 阅读 · 0 评论 -
PYthon 3 安装
#!/bin/bashpy_dist="/data/dba_tools"py_file="${py_dist}/Python-3.6.6.tgz"if [ -z ${py_file} ];then wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz tar -xzf Python-3.6.6.tgz cd ...原创 2020-01-13 10:20:34 · 140 阅读 · 0 评论 -
python 红包
import randomdef red_bao(money,num): money = money * 100 ret = random.sample(range(1,money),num-1) ret.sort() ret.insert(0,0) ret.append(money) for i in range(len(ret)-1): ...原创 2019-06-12 10:45:35 · 559 阅读 · 2 评论 -
python 跑目录下的所有py文件
import osdef func(path): if os.path.isfile(path) and path.endswith('.py'): os.system('python %s' % path) elif os.path.isdir(path): for name in os.listdir(path): a...原创 2019-06-12 10:05:17 · 1271 阅读 · 0 评论 -
python 统计目录大小
import os# 迭代操作# def func(path):# siez_sum = 0# name_list = os.listdir(path)# for name in name_list:# path_abs = os.path.join(path,name)# if os.path.isdir(path_ab...原创 2019-06-11 17:14:40 · 598 阅读 · 0 评论 -
python os模块
os.makedirs('dirname1/dirname2') 可生成多层递归目录os.removedirs('dirname1') 若目录为空,则删除,并递归到上一级目录,如若也为空,则删除,依此类推os.mkdir('dirname') 生成单级目录;相当于shell中mkdir dirnameos.rmdir('dirname') 删除单级空目录,若目录不为空...原创 2019-06-11 13:37:00 · 1376 阅读 · 0 评论 -
python sys模块
import sys# sys 是和python 解释器交互# sys.argv# print(sys.argv) # python 命令的值.# user = sys.argv[1]# pwd = sys.argv[2]# if user == '1234' and pwd == '1234':# print('登陆成功!!!')# else:# ...原创 2019-06-11 11:37:10 · 124 阅读 · 0 评论 -
python time 模块
# 时间戳转换时间print(time.localtime(20000000000))print(time.strftime('%Y%m%d %H:%M:%S',time.localtime(20000000000)))# 时间转换时间戳print(time.strptime('2018-8-8','%Y-%m-%d'))print(time.mktime(time.strptime...原创 2019-06-11 11:07:20 · 129 阅读 · 0 评论 -
Python random 随机生成密码
import randomdef RandomPw(n=20,chars=True): s = '' for i in range(n): list = ['.',',','?','*','+','-','_','/','<','>','~','!','#','@','$','%','^','&','(',')','=','[',']','...原创 2019-06-11 09:35:42 · 1376 阅读 · 1 评论 -
python 日志分析 -redis
#!/bin/python#encoding:utf8import time,re,osfile = open('/data/apps/logs/p4-controller/controller.log.%s' % (time.strftime("%Y-%m-%d", time.localtime())))def Analysis(): sum = 0 times...原创 2019-01-15 14:07:43 · 298 阅读 · 0 评论 -
django 上传文件保存
f = open(img.name.'wb')for line in img.chunks(): f.write(line)f.close()原创 2018-10-30 15:30:40 · 1989 阅读 · 0 评论 -
django form表格,数据实时更新
class TestForm(forms.Form): price = fields.IntegerField() user_id = fields.IntegerField( # widget = widgets.Select(choices=[(0,'1111'),(1,'222222')]) widget = widgets.Select()...原创 2018-10-30 13:38:52 · 2557 阅读 · 0 评论 -
python 线程队列
1.先进先出#!/bin/python#encoding:utf8import queue #线程队列q = queue.Queue() #模式:1.先进先出,2,后进先出,3.优先级#q = queue.Queue(5) #5 表示可以放5个数据q.put(12)q.put('hell')q.put({"name":"wang"})...原创 2018-10-17 09:57:46 · 231 阅读 · 0 评论 -
python sockeserver 实现并发
server 端:import socketserverclass MyServer(socketserver.BaseRequestHandler): def handle(self): print('conn is:',self.request) print('addr is:',self.client_address) whi...原创 2018-10-16 10:21:50 · 390 阅读 · 0 评论 -
基于Python开发的微信图灵机器人
#!/usr/bin/env python3# coding: utf-8from wxpy import *# 微信登陆bot = Bot(console_qr=2,cache_path=True)# 定位群company_group = bot.groups().search('test')[0]# 定位测试人boss = company_group.search('WR')[0]# 初始化图...原创 2018-05-17 07:55:00 · 2818 阅读 · 0 评论 -
python 中 类 子类 属性 方法 对象 self 理解
class a(object): class:定义类 object:表示没有父类 x=1 x=1:定义的一个类属性 def y(self): def y(self): 定义的一个类方法 return 3class原创 2017-08-04 11:06:02 · 25911 阅读 · 0 评论