摘要:os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径os.chdir("dirname") 改变当前脚本工作目录;相当于shell下cdos.curdir 返回当前目录: ('.')os.pardir 获取当前目录的父目录字符串名:('..')os.makedirs('di
阅读全文
07 2019 档案
摘要:os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径os.chdir("dirname") 改变当前脚本工作目录;相当于shell下cdos.curdir 返回当前目录: ('.')os.pardir 获取当前目录的父目录字符串名:('..')os.makedirs('di
阅读全文
摘要:用类的方式创建线程 自创建类 import threadingimport timeclass MyThread(threading.Thread):#自建MyThread类继承threading.Thread类 def __init__(self, num): #init方法用来拿参数,拿到实例变
阅读全文
摘要:server.py import socketserverclass MyServer(socketserver.BaseRequestHandler): #MServer类 继承socketserver.BaseRequestHandler类 def handle(self):#它内部封装的是建立
阅读全文
摘要:实现:client上传图片文件到server 如下图所示,图片与post_client.py在同一当前目录 post_server.py
阅读全文
摘要:在py3中只有两种数据类型:str bytes str: 存unicode(万国码)编码--全球通用的 bytes:存的是16进制的 1.str s='ehllo 丽庆' 》它存在内存中存都是unicode的编码 2.bytes(010101010计算机认识的) 存在磁盘,网络传输等都是bytes类
阅读全文
摘要:类似于cmd的功能,client执行命令,server发命令结果发送到client server.py
阅读全文
摘要:参考:https://www.cnblogs.com/yuanchenqi/articles/5732581.html 一 (简单应用) import logging logging.debug('debug message') logging.info('info message') loggin
阅读全文
摘要:import timedef show_time(f): def inner(*x,**y): #形参 start=time.time() f(*x,**y) #这里也得传参,因为它去执行add函数 end=time.time() print('spend %s' %(end-start)) ret
阅读全文
摘要:现在有一个新的需求,希望可以记录下函数的执行时间,于是在代码中添加日志代码: import time def foo(): start_time=time.time() print('hello foo') time.sleep(3) end_time=time.time() print('spen
阅读全文
摘要:实现的效果如下: 参考www.cnblogs.com/yuanchenqi/articles/5828233.html f(5)=5*4*3*2*1=120 f(7)=7*6*5*4*3*2*1=5040 开始: def fat(n): ret=1 for i in range(1,n+1): re
阅读全文
|