摘要: 我的数据库如图 结构 我取了其中的name age nr,做成array,只要所取数据存在str型,那么取出的数据,全部转化为str型,也就是array阵列的元素全是str,不管数据库定义的是不是int型。 那么问题来了,取出的数据代入公式进行计算的时候,就会类型不符,这是就用到astype(np. 阅读全文
posted @ 2020-06-05 22:07 青女素娥 阅读(10316) 评论(0) 推荐(0) 编辑
摘要: import numpy as npa=[4,5,6,7,8]a=np.array(a)D2=5.5b=abs(a-D2)bmin=min(b)index=np.where(b==bmin)c=a[index]d=max(c)print(d) 向量是a,输入的特定是D2是5.5,向量里最接近5.5的 阅读全文
posted @ 2020-06-05 21:45 青女素娥 阅读(403) 评论(0) 推荐(0) 编辑
摘要: import numpy as np a=np.array([1,2 ,3, 4]) print(len(a)) b=np.array([[ 1000, 100, 10, 1], [35, 9, 1, 5], [22, 12, 3, 2]]) print(len(b)) 当是向量时,len函数返回向 阅读全文
posted @ 2020-06-05 21:38 青女素娥 阅读(1907) 评论(0) 推荐(0) 编辑
摘要: import numpy as np a=np.array([[ 2, 7, 4, 2], [35, 9, 1, 5], [22, 12, 3, 2]]) print(a) #b=a[np.lexsort(a[:,::-1].T)] #print(b) c=np.array([[1,1,1]]).T 阅读全文
posted @ 2020-06-05 20:47 青女素娥 阅读(26793) 评论(0) 推荐(1) 编辑
摘要: import numpy as np a=[] n=1 a=np.hstack((a,n)) n=2 a=np.hstack((a,n)) print(a) b=np.empty((0,1),int) n=1 b=np.vstack((b,n)) n=2 b=np.vstack((b,n)) pri 阅读全文
posted @ 2020-06-05 20:13 青女素娥 阅读(3569) 评论(0) 推荐(0) 编辑
摘要: import numpy as np x=[1,2,3,4] min1=min(x) max1=max(x) print(min1) print(max1) y=np.array([5, 6, 7, 8]) min2=min(y) max2=max(y) print(min2) print(max2 阅读全文
posted @ 2020-06-05 19:26 青女素娥 阅读(917) 评论(0) 推荐(0) 编辑
摘要: import numpy as npa1=np.array([1000, 100, 10, 1])a2 = np.array([[1000], [100], [10], [1]])#a2=np.array([[1000, 100, 10, 1]]).Ta3=np.array([[ 1000, 100 阅读全文
posted @ 2020-06-05 19:11 青女素娥 阅读(2381) 评论(0) 推荐(0) 编辑
摘要: import numpy as np a=np.array([[ 1000, 100, 10, 1], [35, 9, 1, 5], [22, 12, 3, 2]]) b=np.log10(a) print(b) 结果为 阅读全文
posted @ 2020-06-05 18:41 青女素娥 阅读(792) 评论(0) 推荐(0) 编辑
摘要: import matplotlib.pyplot as plt import numpy as np x = np.arange(0, 2*np.pi, 0.02) y = np.sin(x) y1 = np.sin(2*x) y2 = np.sin(3*x) ym1 = np.ma.masked_ 阅读全文
posted @ 2020-06-05 18:38 青女素娥 阅读(2173) 评论(0) 推荐(0) 编辑
摘要: 我输入一个浮点数float好比10.0,我希望将其转化为整形int10,但是输入浮点数10.1的时候,结果仍然保持为浮点数10.1 当输入为10的时候 a=10.0 if int(a)==a: b=int(a) else: b=a print(b) 运行结果 当输入为10.1的时候 a=10.1 i 阅读全文
posted @ 2020-06-05 18:15 青女素娥 阅读(440) 评论(0) 推荐(0) 编辑
摘要: 这是我的数据库student,好比输入一个值为32,查询id最接近32的整行数据,可以用以下代码 import pymysql value=32 conn = pymysql.connect(host='39.106.168.84', user='xxxxxxx', password='xxxxxx 阅读全文
posted @ 2020-06-05 18:02 青女素娥 阅读(974) 评论(0) 推荐(0) 编辑