python获取gbk中文字符
来源:互联网 发布:软件开发自学步骤 编辑:程序博客网 时间:2024/06/05 18:26
# -*- coding: gbk -*-def getGBK(s): i = 0 first = (int('81',16),int('FE',16)) second1 = (int('40',16),int('7E',16)) second2= (int('80',16),int('FE',16)) buf = [] while True: ch1 = ord(s[i]) if ch1 >= first[0] and ch1 <= first[1]: i = i + 1 if i >= len(s): break ch2 = ord(s[i]) if (ch2 >= second1[0] and ch2 <= second1[1]) or \ (ch2 >= second2[0] and ch2 <= second2[1]): buf.append(chr(ch1)) buf.append(chr(ch2)) i = i + 1 else: i = i + 1 if i >= len(s): break print ''.join(buf) getGBK('我 是 谁')getGBK('@我是 谁%$%')getGBK('@我abc是谁%$%')
运行结果
C:\>test.py
我是谁
我是谁
我是谁
- python获取gbk中文字符
- Python对中文字符的处理(utf-8/ gbk/ unicode)
- 【ASP】从URL获取中文字符然后查找数据库后输出GBK中文
- python获取中文字符的拼音简写
- RIDE中的字符转换、中文、python的gbk解码 unicode('${org_name}',"utf-8")
- 【python字符编码汇总】GBK、UTF8、unicode以及中文之间的相互表示
- Java--中文字符转GBK码
- js中获取中文相应gbk编码
- python读取中文gbk编码json文件
- python查找中文字符
- python处理中文字符
- python 中文字符问题
- python中文字符
- Python中文字符问题
- Python处理中文字符
- python中文字符
- python 中文字符问题
- 中文字符处理 python
- 单例模式----设计模式之禅读书笔记
- 黑马程序员--Java异常处理笔记
- python+django的helloworld
- 汉字一级字库与二级字库
- 计算机学习
- python获取gbk中文字符
- Android中包含Header和Footer的无限ListView的实现
- 黑马程序员--子父类中构造函数之间的调用(小结)
- Xcode 4.x 破解及真机调试
- 很早之前想做的一个技术点掌握的分析图表
- spring JDBC总结
- oracle 作业题总结
- TabHost两种实现方法
- NetAdvantage UltraWinTree 绑定(Binding)到类(class)