随笔 - 1762  文章 - 0  评论 - 109  阅读 - 431万

随笔分类 -  Python

上一页 1 2 3 4 5 6 ··· 12 下一页
python求余
摘要:3%3=0 4%3=1 5%3=2 6%3=0 7%3=1 8%3=2 阅读全文
posted @ 2022-05-25 16:07 一杯明月 阅读(57) 评论(0) 推荐(0) 编辑
Python equivalent to 'hold on' in Matlab
摘要:Python equivalent to 'hold on' in Matlab - Stack Overflow Is there an explicit equivalent command in Python's matplotlib for Matlab's hold on? I'm try 阅读全文
posted @ 2022-05-20 21:12 一杯明月 阅读(183) 评论(0) 推荐(0) 编辑
python生成一定间隔的数字列表
摘要:NumPy 从数值范围创建数组 | 菜鸟教程 (runoob.com) NumPy 从数值范围创建数组 这一章节我们将学习如何从数值范围创建数组。 numpy.arange numpy 包中的使用 arange 函数创建数值范围并返回 ndarray 对象,函数格式如下: numpy.arange( 阅读全文
posted @ 2022-05-20 17:47 一杯明月 阅读(2891) 评论(0) 推荐(0) 编辑
np.polynomial.polynomial.polyval
摘要:用法: polynomial.polynomial.polyval(x, c, tensor=True) 在点 x 处计算多项式。 如果 c 的长度为 n + 1,则此函数返回值 仅当参数 x 是元组或列表时,才会将其转换为数组,否则将其视为标量。在任何一种情况下,x 或其元素都必须支持与自身以及与 阅读全文
posted @ 2022-05-20 15:45 一杯明月 阅读(162) 评论(0) 推荐(0) 编辑
python弧度转角度
摘要:角度转为弧度 import math math.radians(x) 弧度转为角度 import math math.degrees(x) 例如: 已知:tan(45°)=1 那么: math.degrees(np.arctan2(1,1))45.0 math.degrees(math.atan(1 阅读全文
posted @ 2022-05-20 15:30 一杯明月 阅读(976) 评论(0) 推荐(0) 编辑
python发出提示音
摘要:在Windows上 import winsound duration = 1000 # millisecond freq = 440 # Hz winsound.Beep(freq, duration) 其中,FREQ是频率(以赫兹为单位),而持续时间是毫秒(毫秒)。 在Linux(和Mac)上 i 阅读全文
posted @ 2022-05-09 19:33 一杯明月 阅读(933) 评论(0) 推荐(0) 编辑
if __name__ == '__main__'的理解
摘要:(12 封私信 / 19 条消息) if __name__ == '__main__' 如何正确理解? - 知乎 (zhihu.com) 阅读全文
posted @ 2022-05-09 16:33 一杯明月 阅读(20) 评论(0) 推荐(0) 编辑
python列表中查找某个元素的索引
摘要:在平时开发过程中,经常遇到需要在数据中获取特定的元素的信息, 如到达目的地最近的车站,橱窗里面最贵的物品等等。怎么办?看下面 方法一: 利用数组自身的特性 a.index(target), 其中a是你的目标list,target是你需要的下标对应的值 a=[72, 56, 76, 84, 80, 8 阅读全文
posted @ 2022-04-17 21:50 一杯明月 阅读(6776) 评论(0) 推荐(0) 编辑
Python判断是字符串还是数字
摘要:python中有一个自带的函数isdigit,可以返回某字符串是不是数字。如果是数字,返回True;反之,返回False。 str1 = '1' print(str1.isdigit()) str2 = '1.1' print(str2.isdigit()) str3 = '-1' print(st 阅读全文
posted @ 2022-04-17 17:25 一杯明月 阅读(2709) 评论(0) 推荐(0) 编辑
python读文件的4种方式
摘要:python读文件的4种方式 - mghhz816 - 博客园 (cnblogs.com) 1.直接打开就读 with open('filepath','r') as f: for line in f: print(line) print('一行数据') 虽然f是一个文件实例,但可以通过以上方式对每 阅读全文
posted @ 2022-04-17 16:39 一杯明月 阅读(2788) 评论(0) 推荐(0) 编辑
python遍历指定后缀名的文件
摘要:方法1: def getFileName(path): ''' 获取指定目录下的所有指定后缀的文件名 ''' f_list = os.listdir(path) # print f_list for i in f_list: # os.path.splitext():分离文件名与扩展名 if os. 阅读全文
posted @ 2022-04-17 15:39 一杯明月 阅读(2926) 评论(0) 推荐(0) 编辑
python画图之plt.plot
摘要:(43条消息) matplotlib.pyplot.plot()参数详解_ims-的博客-CSDN博客_matplotlib plot 【python】Matplotlib作图常用marker类型、线型和颜色 - 大大西瓜吃不饱 - 博客园 (cnblogs.com) plt.plot()函数详细介 阅读全文
posted @ 2022-01-14 22:06 一杯明月 阅读(2831) 评论(0) 推荐(0) 编辑
np.linalg.solve
摘要:矩阵中更高级的一些运算可以在NumPy的线性代数子库linalg中找到。例如inv函数计算逆矩阵,solve函数可以求解多元一次方程组。下面是solve函数的一个例子: >>> a = np.random.rand(10,10) >>> b = np.random.rand(10) >>> x = 阅读全文
posted @ 2022-01-14 21:29 一杯明月 阅读(944) 评论(0) 推荐(0) 编辑
randint()
摘要:python中的random模块用于生成随机数,而要生成随机整数则需要用到 random模块里的randint()函数。randint()函数随机产生括号里两个参数之间的整数,且包括这两个参数,划定随机生成整数的范围(最小最大值)。 1、random.randint()函数原型 random.ran 阅读全文
posted @ 2022-01-14 18:27 一杯明月 阅读(6382) 评论(0) 推荐(0) 编辑
pycharm的project interpretr 安装包时nothing to show
摘要:点击绿色按钮,刷新即可 阅读全文
posted @ 2022-01-12 21:22 一杯明月 阅读(129) 评论(0) 推荐(0) 编辑
win10安装anaconda和Pycharm以及创建虚拟环境
摘要:本文来源:Python 工具——Anaconda+Pycharm 的安装过程 - 知乎 (zhihu.com) 其它参考来源: (41条消息) PyCharm与Anaconda超详细安装配置教程_思绪无限的博客-CSDN博客_anaconda 安装pycharm Python,Pycharm,Ana 阅读全文
posted @ 2022-01-12 18:38 一杯明月 阅读(678) 评论(2) 推荐(0) 编辑
python以追加的方式写文件
摘要:f=open("guru99.txt", "a+") 加号,它表示如果它不存在,它将创建一个新文件。假如已经有了文件,就不需要创建一个新的文件。写成a就行了。 同时使用两个文件 有时你可能想要读取文件并同时写入另一个文件。如果你使用在学习如何写入文件时显示的示例,它实际上可以合并到以下内容中: d_ 阅读全文
posted @ 2021-12-11 21:11 一杯明月 阅读(3118) 评论(0) 推荐(0) 编辑
python 统计数组中某个元素的个数
摘要:import numpy as np a = np.random.randint(-5, 5, (1, 10)) c=np.sum(a>=1) #条件为大于等于1 print ("随机数组a : "+str(a)) #输出数组a print ("大于等于1的个数: "+str(c)) #输出满足条件 阅读全文
posted @ 2021-10-22 21:40 一杯明月 阅读(6769) 评论(0) 推荐(0) 编辑
python在代码完成时调用系统铃声
摘要:import subprocess subprocess.call(['speech-dispatcher']) #start speech dispatcher subprocess.call(['spd-say', '"your process has finished"']) 阅读全文
posted @ 2021-10-15 16:48 一杯明月 阅读(214) 评论(0) 推荐(0) 编辑
np.save
摘要:通过 numpy 读写 txt 或 csv 文件 通过 numpy 读写 npy 或 npz 文件 读写 npy 文件 读写 npz 文件 通过 h5py 读写 hdf5 文件 简单读取 通过切片赋值 总结 References 将 numpy 数组存入文件,有多种文件类型可供选择,对应地就有不同的 阅读全文
posted @ 2021-10-15 16:42 一杯明月 阅读(3553) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 ··· 12 下一页
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示