python实现手机通讯录_Python实现电话簿工具(代码分享)

Python

实现电话簿工具

(

代码分享

)

[python] view plain copy print?# !/usr/bin/python

# -*-

coding:utf-8 -*-

# Filename: phonebook.py

# Author:

qianghaohao(CodeNutter)

# Email:

codenutter@foxmail.com

# ------------------------------------

编码问题

------------------------------------

# import sys

#

import locale

# print sys.getdefaultencoding()

#

系统

的缺省编码

(

一般就是

ascii)

# print

locale.getdefaultlocale()

#

系统当前的编码

# print

locale.getlocale()

#

系统代码中临时被更改的编

# print sys.getfilesystemencoding() #

文件系统编码

# print sys.stdin.encoding

#

终端输入编码

#

print sys.stdout.encoding

#

终端输出编码

#

#

代码缺省编码

:

文件头

# -*- conding: utf-8 -*-

#

-----------------------------------------------------------------------------

---

#

python

中内部编码是

unicode

因此当前

编码要先转换成

unicode

,然后再由

unicode

#

转换成你

需要的编码

.

转换通过

encode

decode

函数

,unicode

相当

于中间编码

.

#

decode

encode

#

str-------------->unicode-------------->str1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值