自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(66)
  • 收藏
  • 关注

原创 vs2008 生成DLL,并在其他工程中调用

最近在工作中需要生成DLL文件,并在其他工程中调用该DLL文件。 首先是生成DLL文件,选择“New Projecgt”->”Win32”->”Win32 Project” ,新建工程名,”Application Settings”选择“DLL”,这样就可以创建DLL工程。这里主要标记下走过的坑: (1)、工程里的函数如果要在其他工程中调用,则需要将函数名导出,常用方法有两种,一种是定义“def

2017-12-08 14:09:21 664

原创 数据处理样例

# -*- coding:UTF-8 -*-import pandas as pdimport numpy as npimport osos.chdir("D:\Ming\Ma") #数据所在路径index = ['TIMESTAMP','TA_F','SW_IN_F','VPD_F','P_F','LE_F_MDS', 'LE_CORR','H_F_MDS','H_CORR','GPP_D

2017-07-18 11:23:40 726 1

原创 distance of vaa3d

import osos.chdir("C:/Program Files/Vaa3D-3.20/bin")import reimport timefrom sqlalchemy import create_engineimport MySQLdbimport pandas as pddef calculate_dist(path): pathDir = os.listdir(pa

2017-05-22 15:55:03 474

原创 get_distance

import osos.chdir("C:/Program Files/Vaa3D-3.20/bin")namelist = []path = "F:/fruitfly_with_gold"pathDir = os.listdir(path)for allDir in pathDir: filepath = path + '/'+allDir file = os.listd

2017-05-21 12:44:16 1913 2

原创 LeetCode Two Sum

def twoSum(nums, target): d={} L = [] for i in range(len(nums)): if (nums[i] in d): L.append(d[nums[i]]) L.append(i) else: d[target-nums[

2017-05-09 17:21:48 240

原创 python 读写文件包含多种编码格式

今天写一个脚本文件,需要将多个文件中的内容汇总到一个txt文件中,由于多个文件有三种不同的编码方式,读写出现错误,先将解决方法记录如下:# -*- coding: utf-8 -*-import waveimport pylab as plimport numpy as npimport pandas as pdimport osimport timeimport datetimei

2017-05-08 17:48:16 3691

原创 几个sql语句

select count(distinct(company_name)) from bj_capital 60/69select count(distinct(company_name)) from bj_capital2 134/193SELECT company_name FROM bj_capital UNION SELECT company_name FROM bj_

2016-12-06 17:45:38 294

原创 提取文章高频词

# -*- coding: utf-8 -*-# * @author haoming# * @date 2016/11/08import MySQLdbimport pandas as pdimport numpy as npimport reimport codecs import jiebaimport jieba.analyseimport loggingfrom gens

2016-12-06 12:47:44 5799

原创 python 写入csv防止乱码

# coding: utf-8import codecsimport osos.chdir("F:\project\predict")import csvcsvfile = open('csv_test.csv', 'wb')csvfile.write(codecs.BOM_UTF8) #防止乱码writer = csv.writer(csvfile)writer.writerow(['姓

2016-12-05 18:44:35 3967 5

原创 根据两个已有表建立新表

create table clue.dust as SELECT distinct c.company_name,c.reg_no, c.city, c.bus_scope, case when b.flag=1 then 1 else 0 end as new_flagFROM (select company_name, reg_no,city,bus_scope,province fro

2016-12-05 10:03:09 481

原创 查询最相似的文档

# -*- coding: utf-8 -*-# * @author haoming# * @date 2016/11/08import osos.chdir(u"G:\project\LRModel\wordseg")import MySQLdbimport pandas as pdimport reimport codecs import jiebaimport jieba.a

2016-11-11 16:27:00 560

原创 sql 查询某一字段包含特定字符的数量

select case when bus_scope like '%婚纱摄影%' then 1 when bus_scope like '%婚庆策划%' then 2 when bus_scope like '%婚庆设备%' then 3 when bus_scope like '%广告策划%' then 4

2016-11-11 12:04:32 13446

原创 python 中文切词并计算相似度

# -*- coding: utf-8 -*-# * @author haoming# * @date 2016/11/08import osos.chdir(u"G:\project")import MySQLdbimport pandas as pdimport reimport codecs import jiebaimport jieba.analyseimport lo

2016-11-09 12:30:35 4335

原创 python 保留两位小数

a = float(10/3.0)print round(a,2) #firstprint "%.2f" % (a) #secondfrom decimal import Decimal#thirdprint Decimal(a).quantize(Decimal('0.00'))

2016-11-02 12:40:41 4508

原创 公交车乘客

s = int(raw_input())L1 = []for i in range(s): L1.append(raw_input())L2 = []for i in range(s): L2.append(int(L1[i][2])-int(L1[i][0]))max = 0sum = 0 for i in range(len(L2)): sum += L2[

2016-10-31 10:55:53 378

原创 约德尔测试

L1 = raw_input()L2 = raw_input()L3 = []for i in range(len(L1)): if L1[i].isalpha() or L1[i].isdigit(): L3.append('1') else: L3.append('0')sum = 0for j in range(len(L3)):

2016-10-31 10:23:23 268

原创 python 变量作用域实例

j,k = 1,2def proc1(): j,k=3,4 print "proc1:j==%d and k==%d"%(j,k) k = 5def proc2(): j = 6 proc1() print "proc2:j==%d and k==%d"%(j,k)k=7proc1()print "j==%d and k==%d" %(j,k)j

2016-10-30 10:25:50 394

原创 输出两字符串中第二个字符串的不同部分

“`def func(x): d={} for i in range(len(x)): d[i] = x[i] return dif name == “main“: A = “qqqq” B = “” d1 = func(A) d2 = func(B) if B == None: pr

2016-10-26 10:26:32 1284

原创 统计字符出现次数

L = "I like data mining, it is pretty good!"L = list(L.strip().split(' '))L = [item.lower() for item in L]print Ld={}for i in range(len(L)): if len(L[i])>1: for j in range(len(L[i])):

2016-10-26 08:50:07 461

原创 去哪网1

方法1:import randomimport copydef func(n): L1 = list(str(n)) L2 = copy.deepcopy(L1) L2.reverse() if L1 == L2: x = n else: n += 1 return func(n) return x

2016-10-15 12:02:39 264

原创 去哪网2

set1,set2 = [set(x) for x in raw_input().strip().split()]if set1 == set2: print "true"else: print "false"判断两个字符串是否由相同字母组成

2016-10-15 12:01:14 219

原创 neuron classification with feature selection

# -*- coding: utf-8 -*-"""Created on Thurs May 26 15:28:03 2016@author: HM"""print(__doc__)import osimport numpy as npimport pandas as pdfrom sklearn.feature_selection import SelectKBest, Select

2016-10-11 11:33:42 571

原创 果蝇神经元聚类

#!/usr/bin/env python# -*- coding: utf-8 -*-"""Created on Sep 26 15:28:03 2016@author: HM"""print(__doc__)from sklearn.cluster import KMeansfrom sklearn.decomposition import PCAfrom sklearn.prepro

2016-09-28 16:29:45 433

原创 爱奇艺 2

#!/usr/bin/env python# -*- coding: utf-8 -*-'''小明喜欢玩一款叫做炉石传说的卡牌游戏,游戏规则如下,玩家拥有N颗水晶和M张卡牌,每张卡牌的使用会消耗ai颗水晶并且造成bi的伤害值,请你帮小明算一下该如何使用手上的卡牌,在消耗小于等于N颗水晶的前提下造成最多的伤害值之和。所有输入均为32位正整数第一行N M第二行到第M+1行 ai bi1

2016-09-27 22:14:12 756

转载 回文数(网易笔试)

# -*- coding:utf-8 -*-#不用递归!--人生苦短我用python#首尾指针跟踪#两个数不相等就进行加法:小的数加上相邻的值def huiwen(item, head, tail): times=0 left = item[0] # head = 0 right = item[-1] # tail = n-1 while (head<tail)

2016-09-26 16:38:05 231

原创 给定数组,输出第三大的数的id

#!/usr/bin/env python# -*- coding: utf-8 -*-def fn(): L = [1,3,9,17,97,37,28,45] d = {} for i in range(len(L)): if L[i] not in d: d[L[i]] = i ss= sorted(d.iteritems

2016-09-23 20:20:56 274

原创 9.20练习

# _*_ coding:utf-8 _*_import osfrom pandas import DataFrame,Seriesimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport pylabimport json''' # usagov_bitly_data2012-03-16-1331

2016-09-20 17:18:36 540

原创 判断字符串子串数

#!/usr/bin/env python# -*- coding: utf-8 -*-def fn(): strs = raw_input("Enter the string:") d = {} for i in range(len(strs)): for j in range(1,len(strs)): if strs[i]*j

2016-09-20 17:17:51 244

原创 9.19练习

# -*- coding: utf-8 -*-def findchar(string,char): num = len(string) for i in range(-1,-(num+1),-1): ff = cmp(string[i],char) if ff == 0: return i else: r

2016-09-19 18:05:48 348

原创 python str, repr

str一般是将数值转成字符串,而repr只是将一个对象转成字符串显示。In [1]: print repr("Hello")'Hello'In [2]: print str("Hello")HelloIn [3]: print eval(repr("Hello"))Hello

2016-09-18 18:47:11 180

原创 京东算法2

def f(x,y,L): sum = (x-L[0])**2+(y-L[1])**2 return sum if __name__ == "__main__": L1 = [] L2 = [] L3 = [] Lx = [] Ly = [] LL = [] for i in range(3): s = i

2016-09-05 21:03:08 1281

原创 京东算法题1

def f1(n): L1 = [] while n>0: L1.append(n%10) n = n / 10 sum1 = Sum_list(L1) return sum1def f2(n): L2 = [] while n>0: L2.append(n%2) n = n/2

2016-09-05 21:02:23 384

原创 python 多线程

#coding=utf-8import threadingfrom time import ctime,sleepdef Music(func): for i in range(2): print "I was listening to %s. %s \n" %(func,ctime()) sleep(1)def Run(): for i in

2016-09-04 10:40:36 165

原创 从txt文件提取数据(神经元特征)

import numpy as npimport osos.chdir("G:\python")def loadDataSet(fileName): fr = open(fileName) L = [] for line in fr.readlines(): curLine = line.strip().split('\t') if

2016-09-02 09:40:21 562

原创 python 读取文件夹下多个文件

import osos.chdir("G:\head in python\hfpy_ch5_data")L=[]for files in os.walk("G:\head in python\hfpy_ch5_data"): for file in files: L.append(file) print(L[2])for i in range(len(L[2

2016-08-26 10:04:04 8222 1

原创 python return

movies=['a','b',['c',['d','e'],'f'],'d']def func(L): for each_item in L: if isinstance(each_item,list): func(each_item) else: print each_item,if __name__==

2016-08-24 11:23:38 408

原创 Neuron Classification2

# -*- coding: utf-8 -*-"""Created on Thurs May 26 15:28:03 2016@author: HM"""print(__doc__)import pandas as pdimport numpy as npfrom pandas import DataFrame,Seriesimport matplotlib.pyplot as plt

2016-08-23 11:19:39 259

原创 Neuron Classification

# -*- coding: utf-8 -*-"""Created on Thurs May 26 15:28:03 2016@author: HM"""print(__doc__)import sysimport osimport timefrom sklearn import metricsimport numpy as npimport cPickle as picklei

2016-08-23 11:18:36 353

原创 Neuron Classification_select models

# -*- coding: utf-8 -*-"""Created on Thurs May 26 15:28:03 2016@author: HM"""print(__doc__)import osimport numpy as npimport pandas as pdfrom sklearn.feature_selection import SelectKBestfrom sk

2016-08-23 11:17:13 366

原创 Neuron Classification_select features

# -*- coding: utf-8 -*-"""Created on Thurs May 26 15:28:03 2016@author: HM"""print(__doc__)import osimport numpy as npimport pandas as pdfrom sklearn.feature_selection import SelectKBestfrom sk

2016-08-23 11:16:35 330

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除