中英文編碼範圍 特殊符號剔除方法

2021-10-04 08:29:55 字數 1026 閱讀 3658

編碼範圍及操作函式

unicode編碼為世界上所有字元都分配了乙個唯一的數字編號,這個編號範圍從 0x000000 到 0x10ffff(十六進製制),它是一種規定,unicode本身只規定了每個字元的數字編號是多少,並沒有規定這個編號如何儲存。而utf-8、utf-16、utf-32都是unicode的實現,只是儲存方式不同。

"®en!f@#$%^&*()_+-={}|\":;'<>?,./ch飛!f@#¥%……&*()——+{}|「:?》《,。、;』【 】、=-~·"

剔除方法一:

from zhon.hanzi import punctuation  #只包含常用中文符號

sign = string.punctuation+punctuation #string.punctuation只包含了英文差用符號

print

(re.sub(r"[%s]+"

% sign,

"", label)

)#>>®enfchf¥ 這結果還有別的特殊符號

puncother = 「®¥」 #補充的特殊字元

sign = string.punctuation+punctuation+puncother

print

(re.sub(r"[%s]+"

% sign,

"", label)

)#>>enfch飛f

label = re.sub(u"([^\u4e00-\u9fa5\u0030-\u0039\u0041-\u005a\u0061-\u007a])",""

, label)

#不在中英文數字範圍的都認為特殊字元

print

(label)

#>>enfch飛f

C 中英文符號互轉

轉全形的函式 sbc case 任意字串 全形字串 全形空格為12288,半形空格為32 其他字元半形 33 126 與全形 65281 65374 的對應關係是 均相差65248 public string tosbc string input if c i 127 c i char c i 65...

特殊符號的英文表示

收藏備用。backquote 反引號 tilde exclam at numbersign,英語國家是hash,美語是pound,裡作sharp,如c dollar percent caret ampersand asterisk,star 美語 數學公式中作multiply parenleft,o...

各種特殊符號的英文叫法

plus 加號 正號 minus 減號 負號 plus or minus 正負號 is multiplied by 乘號 is divided by 除號 is equal to 等於號 is not equal to 不等於號 is equivalent to 全等於號 is less than ...