随笔分类 - language:Python
摘要:https://blog.csdn.net/weixin_39702559/article/details/110971925 #coding:gbk import heapq # 使用heapq实现优先队列 #定义一个可比较对象 class CompareAble: def __init__(se
阅读全文
摘要:剑指 Offer 45. 把数组排成最小的数 输入一个非负整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。 示例 1: 输入: [10,2] 输出: "102" 示例 2: 输入: [3,30,34,5,9] 输出: "3033459" 提示: 0 < nums.l
阅读全文
摘要:基础概念:https://zhuanlan.zhihu.com/p/344754828 import sys import pandas as pd import numpy as np import math # all_list = [] # df = pd.DataFrame(columns
阅读全文
摘要:import numpy as np date = ['20210912', '20210922', '20211009', '20211102'] new_date = [] for i in range(100): new_date.extend(date) new_data = [] for
阅读全文
摘要:# In[1] import os from docx import Document dir_lists = os.listdir() for dir in dir_lists: if os.path.isdir(dir): # print(dir) words_lst = os.listdir(
阅读全文
摘要:from PyPDF2 import PdfFileReader, PdfFileWriter def split(path, name_of_split): pdf = PdfFileReader(path) pdf_writer = PdfFileWriter() for page in ran
阅读全文
摘要:先生成该表格: # In[1] import pandas as pd import os df = pd.read_excel('list.xlsx') ids = df['Pap ID'].to_list() lens = df['Page Length'].to_list() titles =
阅读全文
摘要:https://github.com/garrettj403/SciencePlots Demo import numpy as np import matplotlib.pyplot as plt import matplotlib matplotlib.matplotlib_fname() de
阅读全文
摘要:客户端:(发送数据) import socket import json import time class Client(object): def __init__(self): self.serverIp = '' self.serverPort = 9991 self.bufferSize =
阅读全文
摘要:# In[1] import pandas as pd import numpy as np import json import os import re # In[2] # !pwd os.chdir('./root/FAQ/') # In[2] with open('./data/all_da
阅读全文
摘要:sports = ['跑步', '打球', '打', '强', '壮', '体育', '运动员', '运动', '活动', '训练', '得分', '比赛', '参赛', '赢', '球'] found = NoAQ['question'].str.contains('|'.join(sports)
阅读全文
摘要:pip install package -t dir
阅读全文
摘要:https://blog.csdn.net/strivequeen/article/details/110183863 nohup python -u test.py > test.log 2>&1 & nohup 不挂起的意思 python test.py python 运行test.py文件 -
阅读全文
摘要:import numpy as np >>> a = np.array([11, 22, 33, 4, 5, 6, 7, 8, 9]) >>> b = np.array([11,22,33]) >>> c = np.setdiff1d(a,b) >>> c array([4, 5, 6, 7, 8,
阅读全文
摘要:https://docs.python.org/zh-cn/3/library/argparse.html import argparse parser = argparse.ArgumentParser() parser.add_argument('--dataset-type', type=st
阅读全文
摘要:conda create -n env_name python=3.6 source activate env_name 在root的环境(装jupyter的那个环境): conda install nb_conda # 重新启动 jupyter notebook 使用jupyter就可以方便的切换
阅读全文
摘要:理解:2个样本数据,每个数据3行(T_x = 3),4列(n_value = 4) indices = np.argmax(pred, 2) 例如,对第一个样本数据的,第一行中的,所有数据取最大值的索引下标
阅读全文
摘要:conda config --remove-key channels 更灵活 conda config --set channel_priority flexible
阅读全文
摘要:np.random.seed(0) p = np.array([0.1, 0.0, 0.7, 0.2]) index = np.random.choice([0, 1, 2, 3], p = p.ravel()) 2
阅读全文
摘要:def getRandomIndex(n, x): # 索引范围为[0, n),随机选x个不重复,注意replace=False才是不重复,replace=True则有可能重复 index = np.random.choice(np.arange(n), size=x, replace=False)
阅读全文