
python
文章平均质量分 50
天山懒人
数字IC设计与验证,从事SOC相关行业
展开
-
关于Loaded runtime library: 7402 (compatibility version 7400) but source was compiled with 7005...类型问题
问题描述因为不想自己配环境,所以随便找的一个docker镜像,在跑网络的时候,遇到以下的问题:Loaded runtime library: 7402 (compatibility version 7400) but source was compiled with 7005 (compatibility version 7000). If using a binary install问题分析从这个报错来看,意思就是说,需要的cuda版本应该是7005的,但是你的环境中,cuda的版本是7.4的。原创 2021-01-06 22:41:28 · 312 阅读 · 0 评论 -
pytorch中的tensor以numpy形式进行输出保存
pytorch中的tensor以numpy形式进行输出保存因为tensor和numpy不是一种数据类型,所以,在将数据输出保存之前,需要将tensor的数据类型进行转换,否则会报一下的错误TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.以下先贴一版没修改之前的代码,也就是会报error的。# a是我需要保存的数据原创 2021-01-05 21:16:08 · 7634 阅读 · 0 评论 -
python 微积分计算
from sympy import *t = Symbol('t')x = Symbol('x')m = integrate(sin(t)/(pi-t),(t,0,x))n = integrate(m,(x,0,pi))print n原创 2017-07-18 14:55:02 · 19315 阅读 · 0 评论 -
python正则表达式,向前向后查找与回溯引用
向前向后查找import rekey = r'hello world'#这段是你要匹配的文本#上面的一句也可以利用以下的实现,因为我们一般处理数据都是对文件进行操作的#with open('/Users/Mr.Long/Desktop/data.txt', 'r') as f:# key = f.read()p1 = r"(?).+?(?=)"#这是我们写的正则表达原创 2017-07-25 18:07:00 · 10217 阅读 · 3 评论 -
python zip() 函数使用
参考:http://www.cnblogs.com/frydsh/archive/2012/07/10/2585370.html问题引入:lmbda = sum(x*y for x, y in zip(range(8), num_years))/sum(num_years)当我看到zip(range(8 ) , num_years),的时候,我的第一反应,这是不是在处理压缩包的数据呀?!但转载 2017-07-18 09:48:12 · 1629 阅读 · 0 评论 -
SyntaxError: EOL while scanning string literal问题及解决方法
path1 = 'F:\wamp1\www\stats\'如上面代码所示,在路径的末尾有反斜杠‘\’的时候,会提示你一条错误:【SyntaxError: EOL while scanning string literal】这应该是因为转义字符的问题。所以尝试了一下几种修改方式。正确且是我们想要的: 输入:path1 = 'F:\\wamp1\\www\\stats\\'print(path1)输原创 2017-09-23 14:27:10 · 62623 阅读 · 1 评论 -
【个例】(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated
SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape输入:f = open('C:\Users\Mr.LongKj\Desktop\stats2\result.txt','w')报错: SyntaxError: (unic原创 2017-09-23 15:24:11 · 2889 阅读 · 0 评论 -
python读取多行文件的三种方法
如图多行的数据文件读入,直接上代码。方法一:for line in open(r'C:\Users\Desktop\stat.txt'): print(line)方法二:f = open (r'C:\Users\Desktop\stat.txt','r')lines = f.readlines()for line in lines: print(line)方法三:f = open原创 2017-09-24 19:12:24 · 43036 阅读 · 2 评论 -
Python文件操作,with open as追加文本内容实例
最常见的读写操作import rewith open('/Users/Mr.Long/Desktop/data.txt', 'w') as f: f.write('hello world')就这样就完成了文件的写操错(此处用with的格式,可以节省很多不必要的麻烦)读操作同理,只是做一下微小的变化处理而已with open('/Users/Mr.Long/Desktop原创 2017-07-25 11:12:56 · 87882 阅读 · 5 评论