首页 知识动态 python基础 ( Page 113 )

python基础

python怎么取消多行缩进

ipython缩进和取消缩进快捷键整体缩进(1)Ctrl+】(2)tab取消缩进(1)Ctrl+【(2)shift + tabpycharm缩进和取消缩进快捷键整体缩进(1)tab…

2025-12-01 5,575

python怎样读mat文件格式

mat数据格式是Matlab的数据存储的标准格式,在python中可以使用scipy.io中的函数loadmat()读取mat文件。import scipy.io as scio …

2025-12-01 48,207

python如何打乱list

在java中,打乱list要使用collections.shuffle()方法来实现;python中,要利用random模块中的shuffle()方法来实现。import rand…

2025-12-01 9,040

python怎么转置

方法一 :使用常规的思路def transpose(M):   # 初始化转置后的矩阵   result = []   # 获取转置前的行和列   row, col = shape…

2025-12-01 69,673

python如何求欧几里得

使用列表List作为样本点表示的欧氏距离计算方法:import math # 计算两点之间的距离 def eucliDist(A,B):     return math.sqrt(…

2025-12-01 67,270

python如何获取文件名不带扩展名

Python获取文件名不带扩展名的方法:import os  file_name = os.path.basename(__file__) print(file_name) # 输…

2025-12-01 83,175

python如何判断字符是否大写

例子:>>> str_1 = "HELLO PYTHON" # 全大写 >>> str_2 = "Hello PYTHON" # 大小写混合 >>> str_3 = "Hello …

2025-12-01 10,671

python怎么打sin

描述sin() 返回的x弧度的正弦值。语法以下是 sin() 方法的语法:import math math.sin(x)注意:sin()是不能直接访问的,需要导入 math 模块,…

2025-12-01 35,591

python如何判断变量是否是元组

python的数据类型有:数字(int)、浮点(float)、字符串(str),列表(list)、元组(tuple)、字典(dict)、集合(set)。一般通过以下方法进行判断:1…

2025-12-01 88,607

python 怎么引入类

一、导入单个类from fun import Dog dog=Dog('husike') dog.bark()二、导入多个类多个类之间用逗号分隔from fun import Do…

2025-12-01 10,247