This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// $Id: sphinxclient.c 4097 2013-08-20 09:28:24Z kevg $ | |
// | |
// | |
// Copyright (c) 2001-2013, Andrew Aksyonoff | |
// Copyright (c) 2008-2013, Sphinx Technologies Inc | |
// All rights reserved | |
// | |
// This program is free software; you can redistribute it and/or modify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: UTF-8 -*- | |
import urllib2 | |
import re | |
from datetime import date | |
def get_page(url): | |
"""得到一个网页的内容""" | |
try: | |
print "crawling %s" % url | |
headers = {"User-Agent": "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1) Gecko/20090624 Firefox/3.5",\ | |
"Referer": 'http://www.baidu.com'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
from operator import itemgetter, attrgetter | |
from collections import defaultdict | |
def UserSimilarity(train): | |
#build inverse table for item_users | |
print "build inverse table for item_users" | |
item_users = defaultdict(set) | |
for u,items in train.iteritems(): | |
for i in items.keys(): | |
item_users[i].add(u) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#--*-- encoding:utf-8 --*-- | |
import smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.base import MIMEBase | |
from email import encoders | |
from datetime import date | |
def sendMail(user,pwd,to,subject,filename): | |
outer = MIMEMultipart() | |
outer['From'] = user | |
outer['To'] = to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""统计指定目录下,指定源文件类型的总行数""" | |
from collections import defaultdict | |
import os | |
d = defaultdict(int) | |
path = r"D:/vc++workspaces" #路径 | |
f = ['.c','.cpp'] #需要统计源文件的类型 | |
for dirpath,dirnames,filenames in os.walk(path): | |
for filename in filenames: | |
path = os.path.join(dirpath, filename) |