2019年5月29日
摘要: 首先看下sys模块里的标准输出stdout import sys sys.stdout.write("111") sys.stdout.write("222") 执行结果: 111222 看下带有回车\r的情况 import sys sys.stdout.write("111") sys.stdou 阅读全文
posted @ 2019-05-29 23:56 lilyxiaoyy 阅读(743) 评论(0) 推荐(0) 编辑
摘要: tcp_server.py import socketserver class Myserver(socketserver.BaseRequestHandler): def handle(self): self.data = self.request.recv(1024).strip() # sel 阅读全文
posted @ 2019-05-29 23:02 lilyxiaoyy 阅读(557) 评论(0) 推荐(0) 编辑
摘要: ''' 编码的问题 python2解释器在加载.py文件中的代码时,会对内容进行编码(默认ascii),而python3对内容进行编码的默认为utf-8。 计算机: 早期,计算机是美国发明的,普及率不高,一般只是在美国使用,所以,最早的编码结构就是按照美国人的习惯来编码的。 对应数字+字母+特殊字符 阅读全文
posted @ 2019-05-29 21:07 lilyxiaoyy 阅读(1742) 评论(0) 推荐(0) 编辑
摘要: 服务端: 1.secret_key为bytes类型 2.random_bytes = os.urandom(n) 随机生成一个长度为n的random_bytes server.send(random_bytes)发送给客户端 3.hmac_bytes = hmac(secret_key, rando 阅读全文
posted @ 2019-05-29 19:10 lilyxiaoyy 阅读(383) 评论(0) 推荐(0) 编辑
摘要: hmac: hex-based message authentication code 哈希消息认证码 需要注意传入的key和message都是bytes类型,str类型需要首先编码为bytes。 # coding:utf-8 import hmac secret_key1 = b'This is 阅读全文
posted @ 2019-05-29 11:46 lilyxiaoyy 阅读(7039) 评论(0) 推荐(0) 编辑
摘要: # os.urandom(n)# Return a string of n random bytes suitable for cryptographic use.# This function returns random bytes from an OS-specific randomness 阅读全文
posted @ 2019-05-29 11:27 lilyxiaoyy 阅读(1016) 评论(0) 推荐(0) 编辑
摘要: ftp_server.py # coding:utf-8 import os import json import socket import struct class MyTcpServer(): address_family = socket.AF_INET # AF:address famil 阅读全文
posted @ 2019-05-29 00:41 lilyxiaoyy 阅读(708) 评论(0) 推荐(0) 编辑

返回
顶部