火星文转换器安卓下载-火星文转换器APP下载安装

火星文转换器安卓下载-火星文转换器APP下载安装
浏览 (279)
  • 类型:
  • 更新:2024-07-17
  • 大小:187M
  • 所需权限:查看
  • 隐私政策:查看
:借用py的re模块,寻找可能的火星文,再转换成本土文。 代码: ```python #!/usr/bin/python # -*- coding:utf-8 -*- # 代码功能:将可能存在的火星文转换成本土文 # 利用py的re模块进行寻找和转换 # 区分中英文,保留符号 # 适合在命令行下使用 # author LoveTomorrow import re import sys import codecs # Output code type : utf-8, Heading,but IDE also need to set # So first open a txt which you want to change and save as utf-8 txt = codecs.open(sys.argv[1],'r','utf-8') input = txt.read() txt.close() print input + '\n' # The quotation may happen after the combination of possible chinese and english # it may effinitively spilt out chinese first then recombination two list = re.findall(u'[\u4e00-\u9fa5]+',input) totalInput = re.findall(u'[\u4e00-\u9fa5]',input) def transferAll(n): return re.sub(n,i,turn) # each item from the result of findall for i in totalInput: if i in re.findall(u'[a-z]',input): try: # find English after word temp = totalInput[totalInput.index(i)+1] while temp in re.findall(u'[a-z]',input): # Concatenated before word temp += totalInput[totalInput.index(i)+2] if temp in re.findall(u'[a-z]',input): transfer = ''.join(transferAll(i) for i in temp) input = re.sub(u'((' + temp + u'))', transfer, input) if i + temp not in totalInput: input = re.sub(u'((' + i + u'))', transfer, input) except IndexError: break if input == "": print "Please put Chinese !",-1 sys.exit() print input ```
安卓版下载
火星文转换器安卓下载-火星文转换器APP下载安装

同类推荐更多

专题合集更多>>

终极狂龙-狂龙之怒 宠物小精灵超世代 梦幻国度官方版本下载-梦幻国度官方版 nds模拟器游戏存档位置-nds模拟器游戏