好多人喜欢将 iOS 设置为英文系统,可是有一个问题其实蛮头疼的,就是联系人的排序问题。在英文系统中,全部中文名字被默认排到了 # 后面,而不是按照拼音来分栏的。程序员
网上有一个方法就是将每个你须要排序的名片进行编辑,在 添加项目/Add Field 这一个按钮上点击 Phonetic First/Last Name, 而后将联系人的姓或者名的拼音输入上去。我这里为了方便,在 Mac 中进行编辑,iOS 中同理,没有 MAC 的,能够用苹果帐号登录 iCloud.com 进行联系人管理。code
添加后以下:排序
可是显然,做为程序员是确定不肯意干这个体力活的。 因而咱们能够在 Mac 中或者 iCloud 上将全部的联系人批量选中,而后选择 Export vCard, 将全部联系人导出到本地。图片
而后重命名为 in.vcf,使用 Python3 运行如下程序:input
# Phonetic name adder for vCard # using Python3 f = open('./in.vcf') output = "" for line in f: if line.startswith('N:'): name = line[2:-1].split(";") if name[0] != '': real = name[0] if name[1] != '': real = name[1] print('Input Pinyin for ' + real[0]) output += 'N:' + real[0] + ';' + real[1:] + ';;;\n' output += 'FN:' + real[1:] + ' ' + real[0] + '\n' output += 'X-PHONETIC-LAST-NAME:' + input() + '\n' elif line.startswith('FN:'): pass else: output += line nf = open('./out.vcf', 'w') for line in output: nf.write(line)
程序有一个捉急的点是,咱们须要手工输入姓的拼音,每次输入之后回车便可。 固然咱们能够采用第三方的拼音库能够解决这个问题。it