当前位置:网站首页>Chinese character extraction operation of Sao package (string, no re, in)
Chinese character extraction operation of Sao package (string, no re, in)
2022-04-21 12:00:00 【Dream spirit_ cq】
Python Official website : https://www.python.org/
here , only python the front . Unfortunately, it's the original English version . therefore , I want to practice English reading .🧐🧐
Self study is not a mysterious thing , A person's self-study time is always longer than that in school , There are always more times when there are no teachers than when there are teachers .
—— Hua Luogeng
note : Chinese character extraction of packet

String list with Chinese name :
names = [" Zhang min 15 zhangmin15 ()", " Yang Dandan yangdandan (99999)", " Qian Feng qianfeng (84567)", " Berning bainingning (99999), Teng Yue 3 tengyue3 ()"]
Chinese name character coding interval :
'\u4e00'~'\u9fa5'
Use the Chinese character number coding interval to determine the Chinese character
if ord(k) in range(C_start, C_end+1):
The number range is ,range(19968, 40869+1), Don't change list , Direct efficiency is higher .
It looks like ,“ Can understand its reason ”.🧐
Code running effect

complete Python Code
My solution to the problem , Code comments have been incorporated , I won't repeat it in my blog .
( If you can't make clear the function from the statement annotation , Please leave a message in the comment area for advice and discussion .)
#!/sur/bin/env python
# coding: utf-8
''' filename: /sdcard/qpython/tem.py The dream spirit _cq Code yard '''
from mypythontools import color, wait, cut_line # Load the function to be used in the required code module from the self code tool module .
import re
C_start = ord('\u4e00') # The first Chinese character “ One ” The number code of .
C_end = ord('\u9fa5') # The last Chinese character “ A kind of ” The number code of .
print(f"{
cut_line()} The first character of Chinese character :“{
chr(C_start)}” The number code is “{
C_start}”,\
The last character of Chinese character :“{
chr(C_end)}” The number code is “{
C_end}”.\
{
cut_line()}{
color(1, 'f_green')}\
It can be used {
C_start}~{
C_end} The coding range determines the Chinese character .\
{
color(0)}{
cut_line()}")
names = [" Zhang min 15 zhangmin15 ()", " Yang Dandan yangdandan (99999)", " Qian Feng qianfeng (84567)", " Berning bainingning (99999), Teng Yue 3 tengyue3 ()"]
for i in names: # Traversal extraction .
for j in i.split(','): # Since the last list element is two English comma separated names ,for Insert and apply ',' participle .
tem = []
for k in j:
if ord(k) in range(C_start, C_end+1):
tem.append(k)
print(f"{cut_line()}{'':>6} character string :“{j}”\n\n{'':>12} Chinese name :“{color(''.join(tem), 'f_green')}”{cut_line()}")
wait()
Last one : Personal information extraction ( character string )
my HOT Bo :
- use pandas Solve a small problem (1913 read )
- Iteratable object and four functions (1041 read )
- “ Happy number ” Judge (1200 read )
- Roman digital converter ( Construct element module )(1894 read )
- Rome digital ( converter | Luo )(2526 read )
- Hot: Give Way QQ Group nickname color change code (15586 read )
- Fibonacci sequence ( recursive | for )(3213 read )
- The largest rectangle in the histogram (1623 read )
- Repeat start and end of sorting array elements (1215 read )
- Telephone dialing keyboard letter combination (1272 read )
- Password strength detector (1729 read )
- Find the balance point of the list (1786 read )
- Hot: String statistics (3451 read )
- Hot: Nim game ( Smart version starts )(3322 read ) Nim game ( Optimized version )(894 read )
Recommended conditions
Click to read a thousand
Excellent articles :
- A good writer recommends :《python Complete self study course 》 Qi Wei manuscript free Serial
- OPP The three major characteristics : In the package property
- Understand through built-in objects python'
- Regular expressions
- python in “*” The role of
- Python A complete self-study manual
- Walrus operators
- Python Medium `!=` And `is not` Different
- The right way to learn programming
source : Laoqi classroom
Python Getting started 【Python 3.6.3】
A good writer recommends :
- 【8 Application fields of large programming languages 】 Don't worry about choosing Linguistic Programming , Let's see what they can do first
- Good habits of reliable programmers
CSDN Practical skills blog :
版权声明
本文为[Dream spirit_ cq]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211152167232.html
边栏推荐
猜你喜欢

Chrome开发者工具详解 一

A small game of guessing numbers

Teach you to easily solve CSRF Cross Site Request Forgery Attack

Branch if statement

vscode 经常弹出:尝试在目标目录创建文件时发生一个错误 重试 跳过这个文件 关闭安装程序

华润怡宝被传IPO,农夫山泉或将迎来早年“宿敌”

Solution | fast intercom dispatching system: efficient cooperation

“如何实现集中管理、灵活高效的CI/CD”在线研讨会精彩内容分享

Leaflet military plotting - Assault direction modification (leaflet chapter. 90)

Xinghan will become the co construction unit of finops industry promotion matrix in the future
随机推荐
【软件测试系列九】《压力测试申请需提供事项说明》
[Software Testing Series IV] "test points to be paid attention to in software testing"
Redis interview questions
Chrome开发者工具详解 一
LC刷题第四天
One day, Alibaba database will squeeze Oracle out of the market
Yyds dry goods inventory a common error in a web crawler
Conversion between localdate, localdatetime and date
国网上海直流充电桩专利公布:保证安全运行,全流程检测,分级运维
Kubernetes 服务发现 监控APIServer
Usage Summary of hiredis and rapidjson Libraries
NoSuchBeanDefinitionException - not resolved currently
Analyze the future development direction of GPU
Oracle数据库机越极简越可靠,甲骨文11年前埋的“彩蛋”
笑死!程序员延寿指南开源了
Teach you to easily solve CSRF Cross Site Request Forgery Attack
Cloud native Daas Service - a brief introduction to distributed object storage
sublime主題配色
c语言:指针二(线性表知识+例题详解)
How does PHP determine whether the specified date is the previous day