首页 > 编程知识 正文

用python找多音字(python单词发音)

时间:2023-12-07 13:39:24 阅读:312989 作者:TTTP

本文目录一览:

  • 1、如何用python在一个输入的中文句子中找到指定的中文字或中文词组,并做出翻译?
  • 2、怎么用python re.search找出每个首字母是aeiou的单词
  • 3、用python写一个找单词程序。具体如下。。用上提示的函数
  • 4、如何用Python语言实现在一个文件中查找特定的字符串?

如何用python在一个输入的中文句子中找到指定的中文字或中文词组,并做出翻译?

可以尝试 先将str中数据转换位成 字符编码,然后使用re 正则匹配并替换对应的译文。

怎么用python re.search找出每个首字母是aeiou的单词

可怜的娃,re.findall更简单

 re.findall(r'b([aeiou][A-z]*)b','axxx xxx exxxx')

['axxx', 'exxxx']

用python写一个找单词程序。具体如下。。用上提示的函数

#!bin/python #-*- encoding: utf-8 -*- def counter(path, find, punctuation): infile = open(path, "r") lenth = len(find) count = [] for i in range(lenth): count.append(0) dat = infile.readline().strip("n") while dat != '': dat = dat.split() for elemt in dat: elemt = elemt.strip(punctuation) #去除标点符号 if elemt in find: i = find.index(elemt) count[i] += 1 dat = infile.readline().strip("n") infile.close() for i in range(lenth): print "%s:%d次" % (find[i],count[i]) if __name__ == "__main__": path = "PATH" find = ["hello", "hi", "world"] punctuation = ''',.;'":!?''' counter(path, find, punctuation)

如何用Python语言实现在一个文件中查找特定的字符串?

用正则表达式

 s='hello world'

 import re

 re.search('wor',s)

_sre.SRE_Match object; span=(6, 9), match='wor'

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。