Ejemplo n.º 1
0
 def save(self,
          force_insert=False,
          force_update=False,
          using=None,
          update_fields=None):
     self.slug = '-'.join(lp(str(self.name))) + str(self.pk)
     super(Todo, self).save(force_insert=False,
                            force_update=False,
                            using=None,
                            update_fields=None)
Ejemplo n.º 2
0
 def save(self,
          force_insert=False,
          force_update=False,
          using=None,
          update_fields=None):
     super(Tag, self).save(force_insert=False,
                           force_update=False,
                           using=None,
                           update_fields=None)
     self.slug = '-'.join(lp(str(self.text))) + str(self.pk)  # 之后对pk加个加密啥的
     super(Tag, self).save(force_insert=False,
                           force_update=False,
                           using=None,
                           update_fields=None)
Ejemplo n.º 3
0
#! usr/bin/python
# coding=utf-8
"""
File Name: Tools.py
Description: Some Functions
Date: 2016-11-05
Author: QIU HU
"""

import numpy as np
import pylab as plt
import pypinyin
from pypinyin import lazy_pinyin as lp
import math

print(lp(u'女人'))
Ejemplo n.º 4
0
# -*- coding: utf-8
'''
功能:
将Excel中的汉字转为拼音
如 北京 --> BEIJING
'''
import os
import xlrd
import xlsxwriter
from pypinyin import lazy_pinyin as lp
file_path = os.getcwd() + "/"
read_file = "CityName.xlsx"
out_file = "outCityName.xlsx"
read = xlrd.open_workbook(file_path + read_file)
read_sheet = read.sheet_by_index(0)
rows = read_sheet.nrows
cols = read_sheet.ncols
write = xlsxwriter.Workbook(file_path + out_file)
write_sheet = write.add_worksheet("sheet1")

for row in range(rows):
    name = lp(read_sheet.cell_value(row, 0))
    length = len(name)
    cityName = ''
    for num in range(length):
        cityName += str(name[num])
    write_sheet.write(row, 0, cityName.upper())

write.close()