摘要: list 中 套着 list l = [[1,2],[3,4],[[5,6],[7,8]]] # 如何打印输出字符 5 print(l[2][0][0]) # 该如何理解呢? 去掉外层的嵌套 xx = [[1],[2]] yy= [i[0] for i in xx] print(xx) print( 阅读全文
posted @ 2021-01-27 23:39 emanlee 阅读(1045) 评论(0) 推荐(0)
摘要: python:[numpy] ndarray 与 list 互相转换 # list 转 numpy np.array(list1) # ndarray 转 list array1.tolist() python如何把series转化为list直接list(series)就可以 阅读全文
posted @ 2021-01-27 23:20 emanlee 阅读(6567) 评论(0) 推荐(1)
摘要: PyTorch可以指定用来存储和计算的设备,如使用内存的CPU或者使用显存的GPU。在默认情况下,PyTorch会将数据创建在内存,然后利用CPU来计算。 PyTorch要求计算的所有输入数据都在内存或同一块显卡的显存上。 检测是否可以使用GPU,使用一个全局变量use_gpu,便于后面操作使用 u 阅读全文
posted @ 2021-01-27 22:23 emanlee 阅读(15875) 评论(0) 推荐(0)
摘要: Matplotlib.pyplot 把画图保存为图片 在plt.show()之前执行 plt.savefig() 函数即可。 简单例子: import matplotlib.pyplot as plt x=[1,2,3,4,5] y=[10,5,15,10,20] plt.plot(x,y,'ro- 阅读全文
posted @ 2021-01-27 22:01 emanlee 阅读(17253) 评论(0) 推荐(0)
摘要: list1 = [1,2,3,4,5] list2 = [str(i) for i in list1] list3 = ','.join(list2) 阅读全文
posted @ 2021-01-27 21:55 emanlee 阅读(826) 评论(0) 推荐(0)
摘要: 如果文件名,路径名称,字符串中含有中文汉字,文件头加上这个: #!/usr/bin/python #-*- coding:cp936 -*- 例如: #!/usr/bin/python #-*- coding:cp936 -*- file = 'E:/_申请/横向/' 阅读全文
posted @ 2021-01-27 19:58 emanlee 阅读(4090) 评论(0) 推荐(0)
摘要: https://zh.gluon.ai/chapter_recurrent-neural-networks/lang-model.html 翻译自: https://stackabuse.com/seaborn-library-for-data-visualization-in-python-par 阅读全文
posted @ 2021-01-27 14:34 emanlee 阅读(9688) 评论(0) 推荐(0)
摘要: import datetimeimport timestart = time.time()time.sleep(2) ### 你的代码end = time.time()mystr="run time: %d seconds" % ( end-start)print(mystr) 阅读全文
posted @ 2021-01-27 09:10 emanlee 阅读(789) 评论(0) 推荐(1)