先说一下在123查上面看到的东西
http://www.123cha.com/ip/?q=172.16.156.76
Ipv6扩展地址
Ipv6缩略地址
Ipv6表示地址
2002:ac10:9c4c:0:0:0:0:0
2002:ac10:9c4c::[......]
先说一下在123查上面看到的东西
http://www.123cha.com/ip/?q=172.16.156.76
Ipv6扩展地址
Ipv6缩略地址
Ipv6表示地址
2002:ac10:9c4c:0:0:0:0:0
2002:ac10:9c4c::[......]
最近在弄服务器迁移 遇到一个问题就是服务器上好多中文文件名的文件。以前服务器的管理员不知道是基于什么目的把CentOS默认的字符编码改成GB2312的了 新迁移的Debian是UTF-8的 所以RSYNC过来全部是乱码。想起Ubuntu早期的时候也有这样的windows文件名兼容性问题 挂载的win[......]
实际上是字典举穷,把汉字码表和拼音对应起来了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#!/usr/bin/env python # encoding: utf-8 """ Created by Eric Lo on 2010-05-20. Copyright (c) 2010 __lxneng@gmail.com__. http://lxneng.com All rights reserved. """ class Pinyin(): def __init__(self, data_path='./Mandarin.dat'): self.dict = {} for line in open(data_path): k, v = line.split('\t') self.dict[k] = v self.splitter = '' def get_pinyin(self, chars=u"你好吗"): result = [] for char in chars: key = "%X" % ord(char) try: result.append(self.dict[key].split(" ")[0].strip()[:-1].lower()) except: result.append(char) return self.splitter.join(result) def get_initials(self, char=u'你'): try: return self.dict["%X" % ord(char)].split(" ")[0][0] except: return char |
1 2 3 4 5 6 |
from xpinyin import Pinyin p = Pinyin() p.get_pinyin(u"上海") #输出: 'shanghai' p.get_initials(u"上") #输出 'S' |
下载数据库:http://github.com/lxneng/xpinyin/raw/master/Ma[......]