博客是我工作的好帮手,遇到困难就来博客找资料
发布时间:2018-11-20 12:16:58
1. 字符串转列表str1 = "12345"list1 = list(str1)print list1 str2 = "123 sjhid dhi"list2 = str2.split() #or list2 = str2.split(" ")print list2 str3 = "www.google.com"list3 = str3.split(".")print list3 输出为: ['1', '2', '3', '4', '5']['123', 'sjhid', 'dhi']['www'.........
发布时间:2018-11-14 15:03:19
#百分比转换位小数# -*- coding: utf-8 -*-s = '20%' # 默认要转换的百分比是字符串aa = float(s.strip('%')) # 去掉s 字符串中的 � = aa/100.0 #运行环境是python2.7 其中python2.x 与 python 3x中的除法是有区别print bb# 输出结果是 0.2# 小数转换位百分比#方法一a = 0.32143.........
发布时间:2018-11-12 21:02:25
def writelog(txtname, contests): f = file("/home/haoren/guojia/shanghai/%s" %txtname,'a ') f.write(contests) f.close() returnalldata = []fd = open('/home/haoren/guojia/shanghai/shuju6..........
发布时间:2018-11-02 16:50:55
from elasticsearch import elasticsearchfrom elasticsearch_dsl import search,q,scanes = elasticsearch()1、仿照kibana中的写法q = {"query": {"match": {"name": "easy"}}}res = es.search(body=q)#这中方式返回的结果和kibana查询结果一致,为json2、通过elasticsearch_dsl的search方法s = search().usin.........