自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(18)
  • 收藏
  • 关注

原创 python读取文件最后一行

处理文件时,一个常见的需求就是读取文件的最后一行。那么这个需求用python怎么实现呢?一个朴素的想法如下:with open('a.log', 'r') as fp: lines = fp.readlines() last_line = lines[-1]即使不考虑异常处理的问题,这个代码也不完美,因为如果文件很大,lines = fp.readlines()会造成很大...

2018-11-30 09:53:03 10345 1

原创 pyTorch教程汇总

最好的教程当然是PyTorch的官方文档:PYTORCH DOCUMENTATION(在左边的搜索框内搜索想要的类和方法,就有详细的说明。边学边查,学得最快)PyTorch中文网的PyTorch教程目录:本站 PyTorch 教程目录一篇介绍PyTorch基本操作的博文:PyTorch 深度学习:60分钟快速入门Bilibili上的一个中文视频教程:PyTorch tutorial 神...

2018-11-29 13:10:23 1710

原创 LeetCode周赛#112 Q3 Most Stones Removed with Same Row or Column(连通分量)

题目来源:https://leetcode.com/contest/weekly-contest-112/problems/most-stones-removed-with-same-row-or-column/问题描述 947. Most Stones Removed with Same Row or ColumnOn a 2D plane, we place stones at s...

2018-11-26 22:20:07 405

原创 LeetCode周赛#112 Q4 Bag of Tokens(贪心)

题目来源:https://leetcode.com/contest/weekly-contest-112/problems/bag-of-tokens/问题描述 948. Bag of TokensYou have an initial power P, an initial score of 0 points, and a bag of tokens.Each token can...

2018-11-26 10:13:19 244

原创 LeetCode周赛#112 Q2 Validate Stack Sequences

题目来源:https://leetcode.com/contest/weekly-contest-112/problems/validate-stack-sequences/问题描述 946. Validate Stack SequencesGiven two sequences pushed and popped with distinct values, return true i...

2018-11-26 09:59:21 173

原创 LeetCode周赛#112 Q1 Minimum Increment to Make Array Unique

题目来源:https://leetcode.com/contest/weekly-contest-112/problems/minimum-increment-to-make-array-unique/问题描述 945. Minimum Increment to Make Array UniqueGiven an array of integers A, a move consists...

2018-11-26 09:53:07 148

原创 Learning to Rank for Information Retrieval

信息检索Learning to Rank for Information Retrieval(LETOR) 是Microsoft的一个信息检索相关度排序的数据集,有Supervised rankingSemi-supervised rankingRank aggregationListwise ranking四种setting,提供了数据集下载和evaluation脚本。...

2018-11-25 22:08:43 1881

原创 pandas.DataFrame.plot一个坐标系画多张图片

注意到使用pandas.DataFrame.plot作图会返回一个形如 <pandas.plotting._core.FramePlotMethods object at 0x000001DB45718518>的对象。pandas.DataFrame.plot??,调用函数的帮助:def __call__(self, x=None, y=None, kind='li...

2018-11-21 14:27:58 18877 3

原创 网络不稳定时python爬虫技巧

网络不稳定时,用爬虫下载文件会报ContentTooShortError,类似下面这样:ContentTooShortError: <urlopen error retrieval incomplete: got only 1043679 out of 1050997 bytes>解决思路很简单,就是捕获异常,重新下载。但是如果重新下载的时候网络还是不稳定又遇到ContentT...

2018-11-20 11:28:44 5948 6

原创 python爬虫自动下载网页链接

需求分析今天遇到一个简单的需求,需要下载澳大利亚电力市场NEM日前市场的发电商报价数据(http://nemweb.com.au/Reports/Current/Next_Day_Offer_Energy/),页面观感是这样的:Ctrl + F 一下,看到一共有395个zip链接。于是就想着用python爬虫自动下载。这个网页很简单,没有验证码,甚至不需要登录,因此自动下载的pytho...

2018-11-20 11:14:25 13603 1

原创 LeetCode周赛#111 Q4 Find the Shortest Superstring(状压DP)

题目来源:https://leetcode.com/contest/weekly-contest-111/problems/find-the-shortest-superstring/问题描述 943. Find the Shortest SuperstringGiven an array A of strings, find any smallest string that cont...

2018-11-19 09:42:23 441

原创 LeetCode周赛#111 Q3 DI String Match

题目来源:https://leetcode.com/contest/weekly-contest-111/problems/di-string-match/问题描述 942. DI String MatchGiven a string S that only contains "I" (increase) or "D" (decrease), let N = S.length.Re...

2018-11-18 23:41:20 187

原创 LeetCode周赛#111 Q2 Delete Columns to Make Sorted

题目来源:https://leetcode.com/contest/weekly-contest-111/problems/delete-columns-to-make-sorted/问题描述 944. Delete Columns to Make SortedWe are given an array A of N lowercase letter strings, all of t...

2018-11-18 23:33:39 218

原创 LeetCode周赛#111 Q1 Valid Mountain Array

题目来源:https://leetcode.com/contest/weekly-contest-111/problems/valid-mountain-array/问题描述 941. Valid Mountain ArrayGiven an array A of integers, return true if and only if it is a valid mountain a...

2018-11-18 23:09:06 221

原创 Ubuntu查看所有用户的账号密码

查看用户名用任意账号cat /etc/passwd每行对应一个用户,各列分别为username:password(masked):userId;groupId:comment:homeDir:shell例如da_kao_la:x:1042:1042:,,,:/home/da_kao_la:/bin/bash其中密码一般用`x`或`*`表示查看密码用具有ro...

2018-11-13 22:27:06 58082 7

原创 Linux Anaconda换国内源

1. 在终端下输入两条命令(设置为清华tuna源)conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --set show_channel_urls yes2. 上述命令实际上是修改了~/.condarc文件,用vim打开后可以看到文件内容被修改...

2018-11-11 12:33:00 14536

原创 python初始化指定长度的二维list

在python中,为了实现锯齿数组的数据结构,经常需要初始化一个行数指定、列数可以每行不同的list(np.array是定长的,无法实现锯齿数组变长的需求)。我们首先来回顾一下一维list的初始化。python初始化指定长度的一维list有两种等价的方式方式一a = [None] * n方法二a = [None for i in range(n)]结果都能得到 (n =...

2018-11-10 14:52:49 8707 1

原创 使用git下载项目下的单个文件或目录

因为svn是基于文件存储的,所以用svn可以方便地下载项目下的单个文件或目录,但是git是基于元数据存储的,因此操作会麻烦一些,要用到git的sparse checkout模式。步骤如下:打开git bash,cd到本地项目目录(LocalPro/),创建一个空的本地仓库,把远程仓库的url(remoteURL)加入到config文件中去:cd LocalProjgit initgi...

2018-11-10 11:08:44 12776 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除