Beispiel #1
0
def init():
    global file, en, test, DB, cursor, ip_queue
    en = int(sys.argv[2])
    if en > 0:  # 英文需要传0,中文需要传1
        test = PinYin()
        test.load_word()
    # 打开数据库连接
    DB = MySQLdb.connect("47.99.121.124",
                         "root",
                         "123456",
                         "test",
                         charset='utf8')
    # 使用cursor()方法获取操作游标
    cursor = DB.cursor()
    DB.autocommit(True)
 def pinyin_item(self):
     # pinyin dict
     self.py = PinYin('pinyin/word.data')
     self.py.load_word()
     for i, item in enumerate(self.lis):
         # 拼音化
         han_item = ''
         all_pin = first_pin = ''
         for x in item[0].split(' '):
             han_item += x
         item_pinyin = self.py.hanzi2pinyin_split(string=han_item, split=" ")
         for x in item_pinyin.split(' '):
             if x != '':
                 all_pin += x
                 first_pin += x[0]
         res_pin = item_pinyin + ' ' + all_pin + ' ' + first_pin
         self.lis[i][3] = res_pin
Beispiel #3
0
import json
from collections import OrderedDict

import copy
import requests
import pymongo
import time
from requests.exceptions import RequestException
from datetime import date
from pinyin.pinyin import PinYin

from config import *

py = PinYin()
py.load_word()


class Evcard(object):
    def __init__(self):
        self._data = self.setData()
        #     {
        #         'AreaCodeList': [None, self.saveAreaCodeList,self.saveAreaCodeListToMongo,self.uploadAreaCodeList],
        #         'ShopInfoList': [None, self.saveCityShopInfoList,self.saveCityShopInfoListToMongo,self.uploadCityShopInfoList],
        #         'VehicleModeList': [None, self.saveVehicleModeList,self.saveVehicleModeListToMongo,self.uploadVehicleModeList]
        #     }
        # )
        self.cityDict = None
        self.cityList = None
        self.cityListEN = None
        self._client = self.setClient()