zoukankan      html  css  js  c++  java
  • 07-numpy字符串操作

    import numpy as np
    print(np.char.add(["hello"],["baby"]))#['hellobaby']
    print(np.char.add(["hello","A"],["baby","B"]))#['hellobaby' 'AB']
    print(np.char.multiply("nimei",3))#多个字符串叠加成一个字符串
    print(np.char.center("*",20,fillchar="_"))#字符串填充
    print(np.char.capitalize("nimei"))#返回字符串开头大写
    print(np.char.title("nimeititle,hao are you"))#每个字母开头大写
    print(np.char.lower("ABC"))
    print(np.char.upper("abc"))
    print(np.char.splitlines("hellp 
     123213"))#按行切割
    print(np.char.split("hellp 
     123213",sep="
    "))#按sep切割
    print(np.char.strip(" A A A "))#取出首尾空格
    print(np.char.str_len("ABCD E"))#求长度
    print(np.char.join(":","ABC"))#每个字母拼接:
    print(np.char.join(":",["ABC","EFG"]))#每个字符串每个字母拼接:
    print(np.char.join([":","@"],["ABC,EFG"]))#对应拼接
    print(np.char.replace("hello A","A","B"))#A替换成B
    print(np.char.encode("富强","utf-8"))#编码
    print(np.char.decode(b'xe5xafx8cxe5xbcxba',"utf-8"))#解码
    

      

  • 相关阅读:
    Bzoj1101 [POI2007]Zap
    Bzoj2393 Cirno的完美算数教室
    UVa10891 Game of Sum
    Bzoj4128 Matrix
    类的组合
    继承
    属性查找与绑定方法
    类与对象
    面向对象程序设计——基础概念
    修改个人信息的程序
  • 原文地址:https://www.cnblogs.com/wcyMiracle/p/12423413.html
Copyright © 2011-2022 走看看