![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
Justin01001
记录一些我学习到的东西。
展开
-
python: plt.figure()和plt.legend()有什么用
The purpose of usingplt.figure()is to create a figure object.The whole figure is regarded as the figure object. It is necessary to explicitly useplt.figure()when we want to tweak the size of the figure and when we want to add multiple Axes objects in...转载 2021-09-14 17:10:41 · 951 阅读 · 0 评论 -
python: numpy reshape中的-1含义
简单来说,-1是指reshape之后的array的新形状“面积”是与原始形状相同。-1就表示未知的长或者宽。numpy 允许我们将新的形状参数之一指定为 -1(例如:(2,-1) 或 (-1,3) 但不是 (-1, -1))。 它只是意味着它是一个未知的维度,我们希望 numpy 找出它。 numpy 将通过查看“数组的长度和剩余维度”并确保它满足上述标准来计算这一点。举个例子:z = np.array([[1, 2, 3, 4], [5, 6, 7, 8],翻译 2021-09-10 10:04:55 · 3105 阅读 · 0 评论 -
python: type dtype astype 的用法
1.type 获取数据类型2.dtype 数组元素的类型3.astype 修改数据类型转载 2021-09-10 09:46:25 · 123 阅读 · 0 评论 -
keras: train_test_split中random_state如何理解
train_test_split 将数组或矩阵拆分为随机的训练和测试子集。 这意味着每次在不指定 random_state 的情况下运行它时,都会得到不同的结果,这是预期的行为。 例如:Run 1:>>> a, b = np.arange(10).reshape((5, 2)), range(5)>>> train_test_split(a, b)[array([[6, 7], [8, 9], [4, 5]]), array翻译 2021-09-10 01:06:30 · 2429 阅读 · 0 评论 -
python + selenium: 命名截图并保存到指定文件夹
1,需要导入pathlib的Path类:from pathlib import Path2,截图函数:可以使用以下两种driver.save_screenshot()driver.get_screenshot_as_file()3,实现:i=1scrpath='D:\\Ex3' #指定的保存目录capturename = '\\'+str(i) + '.png' #自定义命名截图wholepath=scrpath+capturenameif Path(scrpat.转载 2021-08-31 16:21:39 · 1426 阅读 · 1 评论 -
python: traceback保留异常日志
try: self.driver.find_element_by_name(name.data).click() except Exception as msg: traceback.print_exc(file = open(r'D:\01_test_results\errorlog.txt', 'a'))需要import trace;控制台的traceback不会显示,而是被写进errorlog.txt文件里。...原创 2021-08-31 15:01:20 · 232 阅读 · 0 评论 -
python: 使用try except做异常捕获
try: # self.driver.find_element_by_name(name.data).click() # 这里填写你的指令 except [这里填写异常的名称,比如:AttributeError] as e: print('错误类型是', e.__class__.__name__) print('错误明细是', e)错误类型是 AttributeError...原创 2021-08-31 12:05:03 · 738 阅读 · 0 评论 -
python: PyFormat %s %d 在python string中的用法
%s 是从 C语言借来的string formatting syntax;#Python2name = raw_input("who are you? ")print "hello %s" % (name,)#Python3+name = input("who are you? ")print("hello %s" % (name,))The%stoken allows me to insert (and potentially format) a string. Notice ...转载 2021-08-31 11:25:45 · 155 阅读 · 0 评论