def ChineseCharCount(str_str) :
count = 0
if str == type(str_str) :
for str_tmp in str_str :
if ord(str_tmp) - ord('0') >= 128 :
count += 1
return count
print(ChineseCharCount(2))
print(ChineseCharCount('里斯kjfweofjhi23#@#$%#$王iowje@#'))
本文介绍了一个简单的Python函数,用于计算字符串中中文字符的数量。通过遍历字符串并检查每个字符的Unicode值,如果该值大于128,则认为是中文字符并进行计数。
8700

被折叠的 条评论
为什么被折叠?



