汉语拼音转换工具 go-pinyin

码农软件 · 软件分类 · 拼音转换工具包 · 2019-08-04 11:58:02

软件介绍

汉语拼音转换工具 Go 版。

安装:go get -u github.com/mozillazg/go-pinyin

安装命令行工具: go get -u github.com/mozillazg/go-pinyin/pinyin

$ pinyin 中国人

zhōng guó rén

示例代码:

package main

import (
    "fmt"
    "github.com/mozillazg/go-pinyin"
)

func main() {
    hans := "中国人"
    a := pinyin.NewArgs()
    // 默认输出 [[zhong] [guo] [ren]]
    fmt.Println(pinyin.Pinyin(hans, a))

    // 包含声调 [[zhōng] [guó] [rén]]
    a.Style = pinyin.Tone
    fmt.Println(pinyin.Pinyin(hans, a))

    // 声调用数字表示 [[zho1ng] [guo2] [re2n]]
    a.Style = pinyin.Tone2
    fmt.Println(pinyin.Pinyin(hans, a))

    // 开启多音字模式 [[zhong zhong] [guo] [ren]]
    a = NewArgs()
    a.Heteronym = true
    fmt.Println(pinyin.Pinyin(hans, a))
    // [[zho1ng zho4ng] [guo2] [re2n]]
    a.Style = pinyin.Tone2
    fmt.Println(pinyin.Pinyin(hans, a))
}

本文地址:https://www.codercto.com/soft/d/11620.html

Python for Everyone

Python for Everyone

Cay S. Horstmann、Rance D. Necaise / John Wiley & Sons / 2013-4-26 / GBP 181.99

Cay Horstmann's" Python for Everyone "provides readers with step-by-step guidance, a feature that is immensely helpful for building confidence and providing an outline for the task at hand. "Problem S......一起来看看 《Python for Everyone》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

MD5 加密
MD5 加密

MD5 加密工具

html转js在线工具
html转js在线工具

html转js在线工具