随笔分类 - python
python socketserver实现服务器端执行命令 上传文件 断点续传
摘要:1 基于socketserver在服务器端实现执行cmd命令和上传文件(断点续传) 2 3 #server: 4 5 #!/usr/bin/env python 6 # -*- coding:utf-8 -*- 7 import subprocess 8 import socketserver 9 import os 10 11 BASEDIR = ...
阅读全文
python 面向对象 类的封装
摘要:1 class Myclass: 2 def f1(self): 3 print(self.ip) 4 print(self.name) 5 print(self.pwd) 6 7 obj = Myclass() 8 obj.ip = '0.0.0.0' 9 obj.name = 'alex' 10 obj.pwd = ...
阅读全文
python json序列化
摘要:1 import json 2 3 d = {"k1":123,"k2":"v2","k3":"v3"} 4 5 s = json.dumps(d) 6 print(s,type(s)) 7 #{"k1": 123, "k2": "v2", "k3": "v3"} 8 9 s = json.loads(s)#字符串内部必须为双引号 10 print(s,type(s)...
阅读全文
python hashlib模块
摘要:1 #实现用户注册登陆 且密码为密文保存 2 #login_password_hash = hashlib.md5(bytes('自己的加密字节',encoding='utf-8')) 不会被撞库 3 4 5 6 import hashlib 7 while 1: 8 mesg = input('1登录2注册\n') 9 if mesg == '2': 1...
阅读全文
python pickle模块
摘要:import pickle dic = { 1001:{ 'name': 'Alex', 'sex': 'male', 'balance': 1000, 'bank_acc':{ 'ICBC': 10001, 'ABC': 10002 } }, ...
阅读全文
python time&datetime模块
摘要:#_*_coding:utf-8_*_ __author__ = 'Alex Li' import time # print(time.clock()) #返回处理器时间,3.3开始已废弃 , 改成了time.process_time()测量处理器运算时间,不包括sleep时间,不稳定,mac上测不出来 # print(time.altzone) #返回与utc时间的时间差,以秒计算\ ...
阅读全文
python 装饰器(可以接收多个值)
摘要:def outer(func): def inner(*arg,**kwargs): print('#####') r = func(*arg,**kwargs) print('*****') return r return inner @outer def f(a,b): return a*b f(3,...
阅读全文
浙公网安备 33010602011771号