Skip to main content

中文识别包

Project description

检测字符串中是否包含中文字符

概述

Unicode 是全球文字统一编码。它把世界上的各种文字的每一个字符指定唯一编码,实现跨语种、跨平台的应用。

中文用户最常接触的是汉字 Unicode 编码。中文字符数量巨大,日常使用的汉字数量有数千个,再加上生僻字,数量达到数万个。下面这个表格将中文字符集的 Unicode 编码范围列出:

字符集 字数 Unicode编码范围
基本汉字 20902 4E00-9FA5
基本汉字补充 74 9FA6-9FEF
扩展A 6582 3400-4DB5
扩展B 42711 20000-2A6D6
扩展C 4149 2A700-2B734
扩展D 222 2B740-2B81D
扩展E 5762 2B820-2CEA1
扩展F 7473 2CEB0-2EBE0
扩展G 4939 30000-3134A
康熙部首 214 2F00-2FD5
部首扩展 115 2E80-2EF3
兼容汉字 477 F900-FAD9
兼容扩展 542 2F800-2FA1D
PUA(GBK)部件 81 E815-E86F
部件扩展 452 E400-E5E8
PUA增补 207 E600-E6CF
汉字笔画 36 31C0-31E3
汉字结构 12 2FF0-2FFB
汉语注音 43 3105-312F
注音扩展 22 31A0-31BA
1 3007

根据上述字符范围,可以使用本工具来识别给定字符串是否含义中文字符。

安装方法

pip install nihao

使用方法

import nihao
a = '这里包含了中文abcded'
b = 'there is no chinese here'

def test_chinese1():
    result = nihao.containChinese(a)
    expected = True
    assert result == expected

def test_chinese2():
    result = nihao.containChinese(b)
    expected = False
    assert result == expected

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nihao-0.1.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nihao-0.1.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file nihao-0.1.1.tar.gz.

File metadata

  • Download URL: nihao-0.1.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for nihao-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cd42d124281f9a1a83b0fed1cb928fdbf0a950e92b9b7fec5b3c2db6cc1f10b5
MD5 d8c6b6be13cc16817863c3c09c782096
BLAKE2b-256 e427963a0581d934287d45f7d01b09d9a5583ecbe44cdf840457b157c0caaea2

See more details on using hashes here.

File details

Details for the file nihao-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nihao-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for nihao-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b370a0e5f01f498d00e9e1075691d20659e7a8d6b1d5b351e98e6a81c16ac08f
MD5 0e8e0605834205c90bd705f50e2db491
BLAKE2b-256 a97638954fc104959f8447903547eb629761a06e2a65a6ca45a0a2e184b0b528

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page