python
sinat_34080511
这个作者很懒,什么都没留下…
展开
-
cos相似度计算
# https://stackoverflow.com/questions/18424228/cosine-similarity-between-2-number-lists# a = [3, 45, 7, 2]# b = [2, 54, 13, 15]# a = torch.Tensor([1, 2, 3])# F.cosine_similarity(a,b, dim=0)# torch.cosine_similarity(a, b,dim=0)# print 1 - spatial.dis.原创 2022-03-02 11:42:59 · 238 阅读 · 0 评论 -
python http
python2python -m SimpleHTTPServer [port]python3python -m http.server [port]接收方:wget IP:port/filename -O filename原创 2021-01-12 11:14:40 · 77 阅读 · 0 评论 -
正则表达式韩语日语
韩语匹配[가-힣]+This matches every character from U+AC00 to U+D7A3日语匹配原创 2017-07-13 19:27:17 · 6663 阅读 · 0 评论 -
写入csv
import csvimport sysimport codecsreload(sys)sys.setdefaultencoding('utf8')with open('out.csv', 'w') as fw: csv_writer = csv.writer(fw,delimiter=' ') with codecs.open(input, 'r', 'utf-8'...原创 2019-01-02 23:16:59 · 238 阅读 · 0 评论 -
bottle处理post json数据请求
客户端import requestsimport jsonheaders = {'content-type':'application/json'}url="http://127.0.0.1:8888/server/" data = { 'mid':"01", 'content':'happy'}r = requests.post(url, data=json....原创 2019-02-25 18:25:37 · 2630 阅读 · 0 评论 -
python测试时间
from timeit import timeitimport rereg = re.compile('look')def find(string, text): if string.find(text) > -1: passdef re_search(string): if reg.search(string): pa...转载 2019-02-20 20:44:28 · 510 阅读 · 0 评论 -
md5
def curlmd5(src): m = hashlib.md5() m.update(src.encode('UTF-8')) return m.hexdigest()原创 2019-03-05 17:25:28 · 1730 阅读 · 0 评论