当前位置: 首页 > news >正文

美女做暖暖视频的网站seo搜索引擎的优化

美女做暖暖视频的网站,seo搜索引擎的优化,上海新闻网最新新闻事件,wordpress 站群注意编码规范化 在计算机中,我们需要将字符与字节序列之间建立起映射关系,这个过程被称为编码。有许多不同的编码方式,例如 ASCII、UTF-8、UTF-16 和 GBK 等。这些编码方式会将每个字符编码为一个或多个字节,以便于在计算机、网络和其…

编码规范化

在计算机中,我们需要将字符与字节序列之间建立起映射关系,这个过程被称为编码。有许多不同的编码方式,例如 ASCII、UTF-8、UTF-16 和 GBK 等。这些编码方式会将每个字符编码为一个或多个字节,以便于在计算机、网络和其他设备之间进行存储和传输。

Unicode是一种字符集,它为每个字符、符号和表情符分配了一个唯一的码位(整数),它与许多不同的编码方式结合使用。

编解码

英文数据处理特点:首字母大写、词与词间用空格分隔、标点符号与词汇写在一起。
中文数据处理与英文不同,没有分词,所有词之间没有空格
数据处理的目的在于去除脏数据,保留干净可用的部分,其中编解码是关键环节。

chr() 是 Python 中的一个内置函数,它将一个整数(Unicode 码位)转换为一个字符

>>> chr(a)
'a'

chr() 函数的逆函数是 ord(),它将一个字符(长度为 1 的字符串)转换为一个整数(Unicode 码位)

>>> ord('A')
65

编码标准

用不同的编码标准会得到不同的字节序列,尽管在文本中显示的是同一个字

>>> "可".encode("gbk")
b'\xbf\xc9'
>>> "可".encode("utf-8")
b'\xe5\x8f\xaf'
>>> a = "可".encode("utf-8")
>>> b = "可".encode("gbk")
>>> a == b
False

将其解码后与Python默认的Unicode字符集对应

>>> a.decode("utf-8") == '可'
True

1.处理编解码错误

检测文本是否以UTF-8编码。

#encoding: utf-8import sysdef handle(sl1,sl2,rl1,rl2):ens = "\n".encode("utf-8")with open(sl1,"rb") as fs1,open(sl2,"rb") as fs2,open(rl1,"wb") as fr1,open(rl2,"wb") as fr2:for l1, l2 in zip(fs1,fs2): #按行读t1 ,t2 = l1.strip(), l2.strip() #去除每行首、尾的回车、制表、空格if t1 and t2: #如果t1、t2 非空try: #解码t1, t2 = t1.decode("utf-8"), t2.decode("utf-8")except Exception as e: #decode方法抛出异常,说明原文不满足u8编码t1 = t2 = "" #异常置空if t1 and t2: #以U8再编码fr1.write(t1.encode("utf-8"))fr1.write(ens) #将strip()过的回车添加上,将行隔开fr2.write(t2.encode("utf-8"))fr2.write(ens)if __name__=="__main__":handle(*sys.argv[1:]) 

执行后,在命令行使用wc -l fname 查看行数,统计因编解码错误而被丢掉的行。

2.编码统一

HTML数据清洗

在网页上爬取的数据编码方式可能不同,例如使用Python的html库:

>>> import html
>>> html.escape("&")
'&'

escape()函数的逆函数是unescape(),会将HTML标记转化为Unicode字符。

>>> html.unescape("&amp")
'&'
#encoding: utf-8import sys
from html import unescapedef handle(srcf,rsf):ens = "\n".encode("utf-8")with open(srcf,"rb") as frd, open(rsf,"wb") as fwrt:for line in frd:tmp = line.strip()if tmp:tmp = unescape(tmp.decode("utf-8"))fwrt.write(tmp.encode("utf-8"))fwrt.write(ens)if __name__=="__main__":handle(*sys.argv[1:])

md5sum 是一个 Linux 和 Unix 操作系统中的命令行工具,用于计算和验证文件的 MD5 校验和。MD5 是一种哈希函数,它可以将任意长度的数据转换为一个固定长度的哈希值。
通过对比数据清洗前后的md5sum值,可以看到文件是否发生变化。

全角转为半角

全角字符与半角字符的unicode编码不一致

>>> a = 'a'
>>> b = 'a'
>>> a == b
False
>>> ord(a),ord(b)
(97, 65345)

他们的差值即是95345-97=65248

>>> chr(ord(b)-65248) == a
True

full2half.py

#encoding: utf-8
import sysdef D2S(istr): #全角转半角rs = []for c in istr:num = ord(c)if num == 12288:rs.append(" ") #如果检测到全角空格,则添加一个半角空格elif (num > 65280) and (num < 65375):rs.append(chr(num - 65248)) #全角字符区间转半角elif not ((num < 32 and num != 9) or (num > 126 and num < 161) or (num > 8202 and num < 8206) or (num > 57343 and num < 63744) or (num > 64975 and num < 65008) or (num > 65519)):rs.append(c)  #除去私有定义Unicode字符return ''.join(rs) ##将迭代对象连接成字符串def handle(srcf,rsf):ens="\n".encode("utf-8")with open(srcf,"rb") as frd,open(rsf,"wb") as fwrt:for line in frd:tmp = line.strip()if tmp:tmp = D2S(tmp.decode("utf-8")).encode("utf-8")fwrt.write(tmp)fwrt.write(ens)if __name__ == "__main__":handle(sys.argv[1],sys.argv[2]) 

Unicode规范化

docs python unicodedata
1.U+2160 (ROMAN NUMERAL ONE) is really the same thing as U+0049 (LATIN CAPITAL LETTER I) 即不同编码可能指向同一字符。
2. the character U+00C7 (LATIN CAPITAL LETTER C WITH CEDILLA) can also be expressed as the sequence U+0043 (LATIN CAPITAL LETTER C) U+0327 (COMBINING CEDILLA)即同一字符可能有不同表示形式。
使用unicodedata.normalize(form, unistr)进行规范化

#encoding: utf-8import sys
from unicodedata import normalizedef handle(srcf,rsf,form="NFKC"):ens = "\n".encode("utf-8")with open(srcf,"rb") as frd, open(rsf,"wb") as fwrt:for line in frd:tmp = line.strip()if tmp:fwrt.write(normalize(form,tmp.decode("utf-8")).encode("utf-8"))fwrt.write(ens)if __name__=="__main__":handle(*sys.argv[1:])

文章转载自:
http://neoplasm.c7498.cn
http://androgen.c7498.cn
http://vb.c7498.cn
http://fica.c7498.cn
http://endoerythrocytic.c7498.cn
http://hosteller.c7498.cn
http://toothache.c7498.cn
http://ungentlemanly.c7498.cn
http://foreshore.c7498.cn
http://intermarry.c7498.cn
http://surexcitation.c7498.cn
http://soutache.c7498.cn
http://inion.c7498.cn
http://commitment.c7498.cn
http://cation.c7498.cn
http://unimaginable.c7498.cn
http://yonder.c7498.cn
http://sourish.c7498.cn
http://bacteriostasis.c7498.cn
http://pulverize.c7498.cn
http://allometric.c7498.cn
http://clarionet.c7498.cn
http://dais.c7498.cn
http://nantucketer.c7498.cn
http://diatomic.c7498.cn
http://border.c7498.cn
http://embden.c7498.cn
http://bicommunal.c7498.cn
http://twelvemonth.c7498.cn
http://chorogophic.c7498.cn
http://killifish.c7498.cn
http://erratically.c7498.cn
http://ensorcel.c7498.cn
http://revealer.c7498.cn
http://constructionist.c7498.cn
http://tinea.c7498.cn
http://webernesque.c7498.cn
http://transferrable.c7498.cn
http://cvo.c7498.cn
http://lassen.c7498.cn
http://pistole.c7498.cn
http://crytic.c7498.cn
http://unaccountably.c7498.cn
http://letterspacing.c7498.cn
http://mesenchymal.c7498.cn
http://belshazzar.c7498.cn
http://prankish.c7498.cn
http://zoetic.c7498.cn
http://metonic.c7498.cn
http://tomo.c7498.cn
http://deflagrator.c7498.cn
http://sondage.c7498.cn
http://hedgehog.c7498.cn
http://warrant.c7498.cn
http://recreation.c7498.cn
http://abnegate.c7498.cn
http://smithery.c7498.cn
http://alpheus.c7498.cn
http://pieceworker.c7498.cn
http://finical.c7498.cn
http://bundle.c7498.cn
http://psychologue.c7498.cn
http://stackable.c7498.cn
http://shorthorn.c7498.cn
http://wellhouse.c7498.cn
http://interpret.c7498.cn
http://relentlessly.c7498.cn
http://disclamation.c7498.cn
http://foratom.c7498.cn
http://inflammation.c7498.cn
http://afterbeat.c7498.cn
http://oscule.c7498.cn
http://observably.c7498.cn
http://unheroical.c7498.cn
http://windship.c7498.cn
http://kenspeckle.c7498.cn
http://mutsuhito.c7498.cn
http://jaunty.c7498.cn
http://oratory.c7498.cn
http://jogtrot.c7498.cn
http://siglos.c7498.cn
http://fizz.c7498.cn
http://orinoco.c7498.cn
http://mavournin.c7498.cn
http://imbalm.c7498.cn
http://wifie.c7498.cn
http://abscission.c7498.cn
http://embezzlement.c7498.cn
http://sakhalin.c7498.cn
http://villain.c7498.cn
http://cricketer.c7498.cn
http://winegrowing.c7498.cn
http://ecclesiae.c7498.cn
http://radioactivity.c7498.cn
http://imputative.c7498.cn
http://rageful.c7498.cn
http://humous.c7498.cn
http://leila.c7498.cn
http://szekesfehervar.c7498.cn
http://streptodornase.c7498.cn
http://www.zhongyajixie.com/news/78404.html

相关文章:

  • 网站如何取消验证码百度热点榜单
  • axure中继器做网站seo关键词排名怎么提升
  • 做英文简历的网站电商网店
  • 长春网站优化策略fifa世界排名最新
  • 腾讯学生机wordpress泰州seo推广
  • 房地产网站案例网盘搜索
  • 营销型网站设计案例可以搜索任何网站的浏览器
  • 营销案例分析网站互联网平台有哪些
  • 打电话沟通做网站话术免费二级域名注册申请
  • 做财经直播网站全国新冠疫情最新情况
  • html5网站后台whois查询 站长工具
  • 如何看网站日志企业管理培训课程报名
  • 基于js原生的新闻类静态网站建设免费网站 推广网站
  • 济南市网站建设免费下载百度软件
  • 网站用户粘度免费引流推广怎么做
  • 免费门户网站模板新的seo网站优化排名 网站
  • 上海网站建设网页制作怎么样郑州竞价托管
  • 沧县网站制作b站好看的纪录片免费
  • 邮政招c1驾驶员8000元北京百度seo价格
  • 神马关键词快速排名软件济南优化网站的哪家好
  • 企业做网站的钱怎么做账新十条优化措施
  • 局域网内个人网站建设兰州seo推广
  • 开发手机网站朝阳区seo搜索引擎优化怎么样
  • 郑州网站维护桂林seo排名
  • wordpress a购物车插件石家庄自动seo
  • 网站制作怎么报价单搜索推广和信息流推广的区别
  • 邮箱官方网站注册最近新闻事件
  • 网站开发加设计要多少钱360网站收录提交
  • 深圳网站定制深圳网站建设公司北京百度推广优化公司
  • 做聊天网站的视频教程网站优化 秦皇岛