摘要:
file_name = 'data_file_pointer.txt'def print_txt(file_name): try: with open(file_name) as f: for line in f.readli... 阅读全文
摘要:
#matplotlibimport matplotlibimport numpy as npimport matplotlib.pyplot as pltdef simple_line(x,y,figure_no): plt.figure(figure_no) ... 阅读全文
摘要:
# Numpy之 点乘、算术运算、切片、遍历和下标取值import numpy as npa = np.arange(4)b = np.arange(4, 11, 2)print(a)print(b)a_plus_b = a + bprint(a_plus_b)a_m... 阅读全文
摘要:
#NumPy之 函数运算import numpy as np#math calculationsprint('math calculations for array:')a=np.array([0,1,2,3])b=np.array([2,-1,2,3])print(... 阅读全文
摘要:
#NumPy之 数组合并和拆分import numpy as np#对数组进行变形a = np.arange(20).reshape((5, 4))print('(5,4):')print(a)a = np.arange(20).reshape((5, -1))pri... 阅读全文
摘要:
#NumPy之 复制和视图(Copies and Views)import numpy as np# ===================================================#不拷贝的情况a=np.arange(12)b=aprint('... 阅读全文
摘要:
# 全局变量(global variable)& 非本地局部变量(nonlocal variable)# 关键字global&nonlocal# ===================================================gcount = 0... 阅读全文
摘要:
# 列表排序import operator as opt# ===================================================# 列表-包含基本类型元素a = [9, 5, 6, 7, 2, 6, 9, 1, 3, 4]a = so... 阅读全文
摘要:
# NumPy之 数组创建import numpy as npdef print_array(a): print(a) print('array dimensions is %d' % (a.ndim)) print('array shape is'... 阅读全文
摘要:
# 过滤器(filter),filter有两个形参,第一个参数返回一个布尔值,# 如果返回True则当前迭代值会被选中,否则不选a = [1, 2, -3, -4, 5, 0.3, -5, 0]print('element in a list:')print(a)#选... 阅读全文