import numpy as np
print ('连接两个字符串:')
print (np.char.add(['hello'],[' xyz']))
print ('\n')
print ('连接示例:')
print(np.char.add(['hello','hi'],['abc','xyz']))
print(np.char.multiply('Runoob',3))
# np.char.center(str , width,fillchar) :
# str: 字符串,width: 长度,fillchar: 填充字符
print (np.char.center('Runoob', 20,fillchar = '*'))
print (np.char.capitalize('runoob'))
print (np.char.title('i like runoob'))
# 操作数组
print(np.char.lower(['RUNOOB', 'GOOGLE']))
# 操作字符串
print(np.char.lower('RUNOOB'))
# 操作数组
print(np.char.upper(['runoob', 'google']))
# 操作字符串
print(np.char.upper('runoob'))
# 分隔符默认为空格
print (np.char.split ('i like runoob?'))
# 分隔符为 .
print (np.char.split ('www.runoob.com', sep = '.'))
# 换行符 \n
print (np.char.splitlines('i\nlike runoob?'))
print (np.char.splitlines('i\rlike runoob?'))
# 移除字符串头尾的 a 字符
print(np.char.strip('ashok arunooba', 'a'))
# 移除数组元素头尾的 a 字符
print(np.char.strip(['arunooba', 'admin', 'java'], 'a'))
# 操作字符串
print(np.char.join(':', 'runoob'))
# 指定多个分隔符操作数组元素
print(np.char.join([':', '-'], ['runoob', 'google']))
print (np.char.replace ('i like runoob', 'oo', 'cc'))
import numpy as np
a = np.char.encode('runoob', 'cp500')
print(a)
a = np.char.encode('runoob', 'cp500')
print (a)
print (np.char.decode(a,'cp500'))
#三角函数
a = np.array([0, 30, 45, 60, 90])
print('不同角度的正弦值:')
# 通过乘 pi/180 转化为弧度
print(np.sin(a * np.pi / 180))
print('\n')
print('数组中角度的余弦值:')
print(np.cos(a * np.pi / 180))
print('\n')
print('数组中角度的正切值:')
print(np.tan(a * np.pi / 180))
a = np.array([-1.7, 1.5, -0.2, 0.6, 10])
print ('提供的数组:')
print (a)
print ('\n')
print ('修改后的数组:')
print (np.floor(a))
a = np.array([-1.7, 1.5, -0.2, 0.6, 10])
print ('提供的数组:')
print (a)
print ('\n')
print ('修改后的数组:')
print (np.ceil(a))
a = np.arange(9, dtype = np.float_).reshape(3,3)
print ('第一个数组:')
print (a)
print ('\n')
print ('第二个数组:')
b = np.array([10,10,10])
print (b)
print ('\n')
print ('两个数组相加:')
print (np.add(a,b))
print ('\n')
print ('两个数组相减:')
print (np.subtract(a,b))
print ('\n')
print ('两个数组相乘:')
print (np.multiply(a,b))
print ('\n')
print ('两个数组相除:')
print (np.divide(a,b))
a = np.array([[3,7,5],[8,4,3],[2,4,9]])
print ('我们的数组是:')
print (a)
print ('\n')
print ('调用 amin() 函数:')
print (np.amin(a,1))
print ('\n')
print ('再次调用 amin() 函数:')
print (np.amin(a,0))
print ('\n')
print ('调用 amax() 函数:')
print (np.amax(a))
print ('\n')
print ('再次调用 amax() 函数:')
print (np.amax(a, axis = 0))