
python
心心喵
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
浏览器复制会报错:Unable to read from the browser‘s clipboard. Please make sure you have granted access for t
你在浏览器中复制内容时遇到“Unable to read from the browser's clipboard”报错,通常是因为。现代浏览器(如Chrome、Firefox、Edge等)出于安全考虑,默认禁止网站随意读取剪贴板内容。当网站尝试复制或粘贴时,需用户明确授权。报错表明:你首次使用该网站的复制功能时,拒绝了权限弹窗;浏览器全局设置禁用了剪贴板权限;网站未使用HTTPS(部分浏览器要求安全连接);广告拦截插件或隐私保护工具阻止了权限请求。原创 2025-05-14 15:43:17 · 1256 阅读 · 0 评论 -
[python] 导入下级目录,导入上级目录
ctrl b 查看是否是正确的路径。原创 2022-10-07 19:11:39 · 388 阅读 · 0 评论 -
[python] 列表list的交集、并集、差集
。。原创 2022-07-29 16:40:07 · 288 阅读 · 0 评论 -
[python] 静态方法staticmethod()、
#!/usr/bin/python# -*- coding: UTF-8 -*- class C(object): @staticmethod def f(): print('runoob'); C.f(); # 静态方法无需实例化cobj = C()cobj.f() # 也可以实例化后调用原创 2022-04-26 14:04:09 · 541 阅读 · 0 评论 -
[python] Numpy矩阵定义、运算 & 生成随机矩阵
一、矩阵定义、运算对多维数组的运算,默认情况并不运算矩阵。如果需要对数组进行矩阵运算,矩阵是继承自numpy数组对象的二维数组对象。Numpy中,矩阵计算是针对整个矩阵中每个元素进行的,与用for循环相比,其在运算速度上更快。import numpy as np #创建numpy矩阵matr1=np.mat('1 2 3;4 5 6;7 8 9') #使用分号隔开数据matr2=np.matrix([[1,2,3],[4,5,6],[7,8,9]) #调用m...原创 2022-04-19 01:40:35 · 7044 阅读 · 0 评论 -
[python] 内置排序 按key排序
内置排序是稳定的!!!!!!!!!!是快排和插入的结合体。TIM排序。一、sorted() 函数与 lambda表达式结合lambda 表达式是 Python 中一类特殊的定义函数的形式,使用它可以定义一个匿名函数。与其它语言不同,Python 的 lambda 表达式的函数体只能有单独的一条语句,也就是返回值表达式语句。1.1使用 lambda 表达式对一维数组进行倒序排序nums = [2, 3, 0, 1, 5, 4]nums1 = sorted(nums, key=lam..原创 2022-04-08 21:28:17 · 783 阅读 · 0 评论 -
[python] 删除首个元素remove,删除元素下标del,pop
removeremove 是删除首个符合条件的元素。remove(2)deldel 是删除指定下标的元素。del l[1]poppop 返回弹出的那个数值。pop(下标)l.pop(1)>>> a = [4, 3, 5] >>> a.pop(1) 3 >>> a [4, 5]...原创 2021-11-17 20:50:41 · 1303 阅读 · 0 评论 -
[python] wav格式问题 file does not start with RIFF id
from sphfile import SPHFileimport os def get_wave_path(wav_path): wave_files = [] for (dirpath, dirname, filenames) in os.walk(wav_path): for filename in filenames: if filename.endswith('.wav') or filename.endswith('.WAV'): filename_path = os原创 2021-06-29 13:22:42 · 2465 阅读 · 1 评论 -
[python] pycurl包安装, libcurl link-time version (7.58.0) is older than compile-time version (7.68.0)
python3.7下安装Pycurl报错:libcurl link-time version (7.58.0) is older than compile-time version (7.68.0)解决方案尝试了网上所有的解决办法都失败了最终用以下方法解决的:成功方法conda install pycurl、对数正态、负指数、伽马和贝塔分布的函数。为了生成角度分布,可以使用 von Mises 分布。几乎所有模块函数都依赖于基本函数 random() ,它在半开放区间 [0.0,1.0) 内均匀生成随机浮点数。Python 使用原创 2021-06-07 15:30:40 · 3550 阅读 · 1 评论 -
[python] Python读写txt文本文件
https://www.cnblogs.com/hackpig/p/8215786.htmlPython读写txt文本文件原创 2021-06-01 12:36:48 · 142 阅读 · 0 评论 -
[python] jupyter中python解压缩
zip解压:利用zipfile模块import zipfilef = zipfile.ZipFile("./CNN.zip",'r') # 原压缩文件在服务器的位置for file in f.namelist(): f.extract(file,"./") #解压到的位置,./表示当前目录(与此.ipynb文件同一个目录)f.close()rar解压:利用rarfile模块# rar文件解压类似# 如果是rar文件解压,也是类似,from unrar import rarfilefi原创 2021-05-12 16:45:52 · 3171 阅读 · 0 评论 -
[python] 文件夹拷贝copy
Python-文件夹的拷贝操作参考:https://www.cnblogs.com/wangzhilong/p/11986994.html在Python中,想要实现文件夹的拷贝,需使用shutil包,其中文件复制的内置函数为shutil.copy这里介绍两种拷贝方式:第一种为文件夹整体拷贝:import osimport shutilsource_path = os.path.abspath(r'E:\Projects\source_dir')target_path = os.path.a原创 2021-05-07 11:27:26 · 1512 阅读 · 0 评论 -
[jupyter] python3并行下载文件url
import geventfrom gevent import socketfrom gevent import monkey; monkey.patch_all()import sys# import urllib2 py3弃用import urllib.requestdef download(url): try: url_opener = urllib.request.urlopen(url) except: print 'o原创 2021-05-06 12:06:30 · 333 阅读 · 0 评论 -
[python] 读取文件大小,统计文件数目,压缩效率
参考:https://www.cnblogs.com/benben-wu/p/12411316.html参考:https://blog.youkuaiyun.com/w55100/article/details/92081182参考:https://blog.youkuaiyun.com/dbllw8293/article/details/101815959参考:https://blog.youkuaiyun.com/qq_34924407/article/details/83063748读取文件夹/文件大小读取文件夹大小其实就原创 2021-05-06 09:18:50 · 607 阅读 · 0 评论 -
[python] np.diff()差分
import numpy as npA = np.arange(2 , 14).reshape((3 , 4))A[1 , 1] = 8print('A:' , A)# A: [[ 2 3 4 5]# [ 6 8 8 9]# [10 11 12 13]]print(np.diff(A))# [[1 1 1]# [2 0 1]# [1 1 1]]原创 2021-04-19 10:06:17 · 2012 阅读 · 0 评论 -
[python] print: {}-style、f-strings
https://www.python-course.eu/python3_formatted_output.phphttps://docs.python.org/3/reference/lexical_analysis.html#f-strings建议使用 {}-style格式 而不是 %-style格式:print("a=%d,b=%d" % (f(x,n),g(x,n)))// ‘‘.format()print('a={:d}, b={:d}'.format(f(x,n),g(x,n)))/原创 2021-04-16 02:28:22 · 221 阅读 · 0 评论 -
[python] lambda表达式
https://www.cnblogs.com/caizhao/p/7905094.htmlg = lambda x:x+1g(1)>>>2g(2)>>>3lambda x:x+1(1)>>>2 >>> foo = [2, 18, 9, 22, 17, 24, 8, 12, 27]>>>>>> print filter(lambda x: x % 3 == 0, fo原创 2021-04-16 02:15:44 · 181 阅读 · 0 评论 -
[python] python main函数
参考:https://lance.moe/post-301.html作用Python使用缩进来对代码组织并执行,所有没有缩进的代码(非函数定义、类定义),都会在载入时自动执行,这些代码,都可以认为是Python的main函数内的代码。print('hello world!')相当于def main(): print('hello world!')main()为了区分主执行文件还是被调用的文件,Python引入了一个变量__name__,当文件是被调用时,__name__的值为模原创 2021-04-16 01:34:23 · 2840 阅读 · 0 评论 -
[python] zip和*zip
https://www.cnblogs.com/kenny-feng/p/11368477.htmlzip():压缩zip():解压zip(a,b):将a和b中的元素对应组合成元组。而要想看到这个结果,需用zip()函数*zip(a,b):让zip可视化但若先 t = zip(a,b),再print(t)的话,没有任何返回值,因为zip()中的 * 和zip是连用的,不能将它们分开用...原创 2020-02-27 18:53:10 · 206 阅读 · 0 评论 -
[python] Jupyter notebooks上传文件夹或大量数据到服务器
https://blog.youkuaiyun.com/weixin_40957741/article/details/91126638解压缩文件import zipfileimport osfiles = zipfile.ZipFile('homework.zip', 'r')files.extractall(os.getcwd())files.close() 打包成zip但是,有时...原创 2020-02-11 20:58:40 · 359 阅读 · 0 评论 -
[python] nltk 报错[nltk_data] Error loading stopwords: hostname
下载stopwordsimport nltkimport ssltry: _create_unverified_https_context = ssl._create_unverified_contextexcept AttributeError: passelse: ssl._create_default_https_context = _create_unv...原创 2020-02-08 16:48:14 · 1585 阅读 · 0 评论 -
[python] 正则“^[a-zA-Z]” 和 “[^a-zA-Z]”的区别
^ [a-zA-Z]是去匹配目标字符串中以中括号中的a—z或者A—Z开头的字符[^a-zA-Z]是去匹配目标字符串中非a—z也非A—Z的字符.原创 2020-02-08 16:42:28 · 3258 阅读 · 0 评论 -
[nlp] Tensorflow-RuntimeError:无法在Tensorflow图函数中获取值
https://stackoverflow.com/questions/55665682/tensorflow-runtimeerror-cannot-get-value-inside-tensorflow-graph-function我认为您正在使用Tensorflow 2.0。如果是这种情况,则使用参数embeddings_initializer=代替weights=有效。...原创 2019-12-08 13:40:16 · 926 阅读 · 0 评论 -
[python] 指定gpu
在终端执行程序时指定GPUCUDA_VISIBLE_DEVICES=1 python your_file.py这样在跑你的网络之前,告诉程序只能看到1号GPU,其他的GPU它不可见可用的形式如下:CUDA_VISIBLE_DEVICES=1 Only device 1 will be seenCUDA_VISIBLE_DEVICES=0,1 De...原创 2019-12-07 16:08:16 · 397 阅读 · 0 评论 -
[python] pip安装太慢
https://blog.youkuaiyun.com/e15273/article/details/79649876 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jieba原创 2019-12-07 13:53:23 · 204 阅读 · 0 评论 -
[python] matplotlib中更改plt.plot()的绘图风格
import numpy as npimport matplotlib.pyplot as pltimport matplotlib as mplplt.style.use('ggplot') np.random.seed(1)data = np.random.randn(50)plt.plot(data)plt.show()print(len(plt.style.availa...原创 2019-11-10 19:29:14 · 950 阅读 · 0 评论 -
[python] import.io.data报错&&pandas_datareader报错
利用python进行数据分析书中,import.io.data报错根据路径,找到https://github.com/pydata/pandas-datareader原创 2019-11-06 21:18:18 · 545 阅读 · 0 评论