![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
MAGDB
这个作者很懒,什么都没留下…
展开
-
Python和C程序运行的区别
Python对字节码进行一句句的解释执行(类似生成了一个可执行的序列)可以看到,C编译得到汇编语言,python编译得到字节码。为了更好的展示Python和C程序运行的区别给出下图。C对汇编语言经过汇编和链接得到一个可以执行的整体。原创 2022-11-20 16:36:59 · 221 阅读 · 0 评论 -
Python 通过类名来调用类
字符串调用类下面的算法可以通过输入字符串调用类from .a import Afrom .b import Bfrom .c import Cdef get_cls(name): sn = sys.modules[__name__] c = [i for i in dir(sn) if callable(getattr(sn, i))] temp_list = [current_usr.lower() for current_usr in c] if name.l原创 2021-10-24 10:00:15 · 891 阅读 · 0 评论 -
python判断两路径是否相同
os.path.samefile(path1, path2)# 如果两个路径都指向相同的文件或目录,则返回 True。如果有必要os.path.normcase(path)# 规范路径的大小写。参考python文档原创 2021-09-21 20:04:46 · 2673 阅读 · 0 评论 -
python mat转npy或csv
import numpy as npimport pandas as pdimport scipy.io as siofeatures_struct = sio.loadmat('./warpAR10P.mat')features = list(features_struct.values()) features = np.hstack((features[-2], features[-1]))# 保存为csvdfdata = pd.DataFrame(data=features)df原创 2021-07-21 19:29:30 · 263 阅读 · 1 评论 -
python装饰器
什么是装饰器装饰器装饰器最常见的用处时保存日志简单的例子def decorator(func): def wrapper(*args, **kwargs): print('This is a test') return func(*args, **kwargs) return wrapper@decoratordef test(): print('这是一个测试')test()运行结果This is a test这是一个测试原创 2021-07-16 09:08:12 · 56 阅读 · 0 评论 -
np.shuffle()使用
使用时间作为随机种子import randomimport timeindex = [16, 20, 10, 5]random.seed(time.time())random.shuffle(index)原创 2021-04-26 10:13:55 · 837 阅读 · 0 评论 -
pyqt翻译软件
编写原因有时需要翻译pdf,而且pdf复制后的文本格式需要整理一下才能更好的阅读随便实现了一下,仅实现了功能,写的不好开发环境语言:python3.6系统:win10百度翻译api注册的百度翻译开发者使用的通用翻译实名认证后可以使用高级版,标准版其实也够用注册地址我写得这个必须要注册,因为需要appid和秘钥,填写两个变量的位置在程序中留出空了运行效果剪贴板翻译打钩后,就可以直接获取剪贴板内容翻译ctrl+shift+c是翻译的快捷键程序要使用的话注意appid和秘钥不要忘原创 2020-12-15 16:34:16 · 151 阅读 · 0 评论 -
pynvml运行错误
环境Windows 10(1903)NVIDIA studio 456.38 驱动问题安装完驱动后发现 C:\Program Files\NVIDIA Corporation\NVSMI 里面是空的,所以会出现以下错误Traceback (most recent call last): File "D:\Python\Python36\lib\site-packages\pynvml.py", line 641, in _LoadNvmlLibrary nvmlLib = CDLL原创 2020-10-25 11:04:44 · 2335 阅读 · 2 评论 -
argmax,nanargmax,nanmax区别
np.argmax(a)返回包括Nan在内的最大值的索引np.nanargmax(a)返回Nan之外的最大值的索引np.nanmax(a)返回最大值代码import numpy as npa = np.array([[np.nan, 4], [2, 10]])print(a)np.argmax(a)np.nanargmax(a)np.nanmax(a)输出:[[nan 4.] [ 2. 10.]] 0310.0...原创 2020-09-26 15:59:32 · 1436 阅读 · 0 评论 -
Python Turtle 3维柱形图冒泡排序
from turtle import *from random import *import timedef bubble_sort(rectangle_list): for passnum in range(0, 10 - 1): for i in range(0, 10 - passnum - 1, 1): if rectangle_...原创 2019-03-27 14:27:15 · 448 阅读 · 0 评论