zoukankan      html  css  js  c++  java
  • pinyin获取汉字首字母

    def test_get_initial(self):
    self.assertEqual(pinyin.get_initial('你好'), u('n h'))
    self.assertEqual(pinyin.get_initial('你好吗?'), u('n h m ?'))
    self.assertEqual(pinyin.get_initial('你好吗?'), u('n h m ?'))
     
    self.assertEqual(pinyin.get_initial('你好'), 'n h')
     
    def test_get_initial_with_delimiter(self):
    self.assertEqual(pinyin.get_initial('你好', "-"), u('n-h'))
    self.assertEqual(pinyin.get_initial('你好吗?', "-"), u('n-h-m-?')) self.assertEqual(pinyin.get_initial('你好吗?', "-"), u('n-h-m-?'))
     
    注释:使用lower()方法将字符串转成小写
    更多例子
    str = "www.runoob.com" print(str.upper()) # 把所有字符中的小写字母转换成大写字母
    print(str.lower()) # 把所有字符中的大写字母转换成小写字母
    print(str.capitalize()) # 把第一个字母转化为大写字母,其余小写
    print(str.title()) # 把每个单词的第一个字母转化为大写,其余小写
    更多例子
    [Gèng duō lìzi]
    More examples
    满足不是幸福,平平淡淡才是真
  • 相关阅读:
    python_6
    python_day4
    python_day3
    python_day2
    python
    python入门
    jQuery之前端国际化jQuery.i18n.properties
    转载!网页中插入百度地图
    jQuery.validate 中文API
    Web移动端Fixed布局的解决方案
  • 原文地址:https://www.cnblogs.com/xing03/p/12507794.html
Copyright © 2011-2022 走看看