自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

zxc120389574的博客

谨慎乐观。

  • 博客(417)
  • 收藏
  • 关注

原创 【python】用pickle保存数据到文件中

以二进制的形式保存:import pickle# 写入pickledef pickle_write(file_path, data): f = open(file_path, 'wb') pickle.dump(data, f) f.close()# 读取pickledef pickle_read(file_path): f = open(file_path, 'rb') data = pickle.load(f) return data.

2021-05-13 17:35:51 875

原创 【python】unicode编码转换成中文str

假设unicode编码保存在text变量中。如果type(text)是bytes:text.decode('unicode_escape')如果type(text)是str:text.encode('latin-1').decode('unicode_escape')转自:https://www.zhihu.com/question/26921730

2021-01-16 18:08:56 685

原创 搜索引擎高级搜索

前言:通过多次在谷歌和百度上使用高级搜索,发现,百度与谷歌在收录词条和查询精度上均有较大差距,故推荐在谷歌上使用高级搜索以提高效率。常用的高级搜索指令:site,filetype,逻辑与或、逻辑非、双引号、通配符*、intitle、allintitle、inurl、allinurl、intext、allintext更详细:更详细的高级搜索看下面这篇博文,包括搜索引擎高级搜索和本地搜索,整理得非常直观非常好:https://cloud.tencent.com/developer/article/1

2021-01-09 22:41:33 930

原创 《剑指offer》所有面试题的笔记总结

*建议:还是以书为主,然后以我的笔记为辅助。C#不太了解,所以没放书上的代码。博文https://www.cnblogs.com/james111/p/7003100.html对这个问题分析得很全面。思路很简单,每个元素的值就是ta应该所处的数组下标,然后不断地归位就可以了。我的笔记如下:这个题目相比上一个题目,难在“不能修改数组”上。所以思路是这样的:以题目中的数组为例,长度为8,范围是1~7。从中间将其范围划分成两组:1~4一组,5~7一组。然后对值为1~4和值为5~7的数字进行计

2020-12-28 18:02:43 376

原创 面试题44:数字序列中某一位的数字

思路:规律如下表:数字的区间范围范围内所有数字的总位数0~91 * 1010~992 * 901000~9993 * 90010000~99994 * 9000……规律很明显,剩下的就是编程细节。计算公式在草稿上。草稿如下:代码实现及验证:#include <iostream>using namespace std;int function(int target) { target += 1; int i

2020-12-28 17:47:56 85 1

原创 【tkinter】用label显示和更新图像时,图像总是一闪而过

假设你已经创建了一个label,我们要用点击一个button去更新这个图像,但是就闪一下。解决方法很简单,在你的button响应函数中使用下面代码更新图像就可以了:tkImage = ImageTk.PhotoImage(image=Image.fromarray(np.int32(origin_img * 255))) # origin_img是你要显示的图像,类型是一个array数组。img_left.configure(image=tkImage) # 这里要配置一下img_left.image

2020-12-15 15:53:37 1717

原创 pycharm远程运行tkinter失败:_tkinter.TclError: couldn‘t connect to display “:10.0“

错误如下:代码如下(代码是没有问题的):from tkinter import*#初始化Tk()myWindow = Tk(screenName = ':10.0')#设置标题myWindow.title('Python GUI Learning')#创建一个标签,显示文本Label(myWindow, text="user-name",bg='red',font=('Arial 12 bold'),width=20,height=5).pack()Label(myWindow, tex

2020-12-11 16:09:47 1934 1

原创 VsCode远程服务器开发的配置方法

直接看博文https://zhuanlan.zhihu.com/p/95678121。这个方法的强大之处在于,它不是对本地文件和服务器文件进行同步,而是直接操作服务器上的文件。

2020-12-08 15:14:13 461

原创 windows上搭建服务器,超简单

下载phpStudy软件即可。

2020-12-08 10:58:20 976

原创 Ubuntu上搭建Ajenti控制面板

直接看博文https://ywnz.com/linuxyffq/7309.html,亲测有效。

2020-12-07 14:04:34 284

原创 面试题60:n个骰子的点数(补充解释)

前言: 书上的解释太简单了,在此补充解释下。思路: 利用动态规划,不断地迭代即可。动态规划的公式为:dp[i][j] = dp[i-1][j-1] + dp[i-1][j-2]+dp[i-1][j-3]+dp[i-1][j-4]+dp[i-1][j-5]+dp[i-1][j-6]。例:假设有5个骰子,具体计算如下。实际上只需要两行的空间(2个长度为30的数组)交替运算就可以,这便是书中的算法。代码实现:#include <iostream>#include <assert.

2020-12-06 22:41:10 147

原创 【Tampermonkey】知乎自动邀请回答脚本

注:24小时内最多邀请250次。运行效果如下:代码实现:// ==UserScript==// @name 知乎脚本-一键邀请// @namespace http://tampermonkey.net/// @version 0.1// @description try to take over the world!// @author You// @match https://www.zhihu.com/question

2020-12-06 21:37:45 954 8

原创 面试题43:1~n整数中1出现的次数(自己实现)

前言:剑指offer第43题,书上讲解没看明白,故自己进行了研究。思路如下:1、求出dp数组的值。dp[i]表示0到10^i-1内所有数字中“1”出现的次数。归纳一下便可发现规律:dp[0] = 0dp[1] = 10 * dp[0] + 1dp[2] = 10 * dp[1] + 10dp[3] = 10 * dp[2] + 100dp[4] = 10 * dp[3] + 1000dp[5] = 10 * dp[4] + 10000dp[6] = 10 * dp[5] + 100000

2020-12-05 20:24:52 101

原创 面试题19:正则表达式匹配(通俗易懂版代码)

把剑指offer上的代码全部展开,然后重写了一下并详细解释,感觉这样更好理解一些。代码实现如下:#include <iostream>#include <assert.h>using namespace std;bool matchCore(char *str, char *pattern);bool match(char* str, char* pattern) { if (str == nullptr || pattern == nullptr) return

2020-12-04 17:42:55 105

原创 【FFmpeg】下载百度百科视频

步骤:1、分析百度百科的NetWork数据,找到.m3u8(Name中带有分辨率)地址。2、用FFmpeg将.m3u8转换成.mp4格式并下载:ffmpeg -i https://baikevideo.cdn.bcebos.com/media/mda-Og4A7OML8EqV0Umy/dbb7639b76a9acead248ee771a8e48d5_1280x720_1538000.m3u8 -acodec copy -vcodec copy video.mp4参考:https://www.

2020-11-29 17:04:46 774 1

原创 【leetcode】179. Largest Number

题目:Given a list of non-negative integers nums, arrange them such that they form the largest number.Note: The result may be very large, so you need to return a string instead of an integer.思路:将ab和ba进行比较,以此来排序nums数组。代码实现:class Solution {public:

2020-11-17 17:22:28 83

原创 【leetcode】145. Binary Tree Postorder Traversal

题目:Given the root of a binary tree, return the postorder traversal of its nodes’ values.思路:p沿着left一直往下走,同时入栈p指向的node。关键时回溯的时候,我设立了一个flag(map<TreeNode*, bool>)用来标记回溯时,当前节点的父节点是否应该从栈中弹出。如果是false,则不应该弹出;否则应该弹出,并将其值加入到ans中。然后我又想了一下,既然仅仅是对node做一个标记,那

2020-11-16 23:22:24 77

原创 【Tars】CoroutineScheduler中各函数的解释

核心数据结构:CoroutineInfo** _all_coro; // 存放所有协程的数组指针CoroutineInfo _active; // 活跃的协程链表CoroutineInfo _avail; // 可用的协程链表CoroutineInfo _inactive; // 不活跃的协程链表CoroutineInfo _timeout; // 超时的协程链表CoroutineInf

2020-11-08 22:39:47 194

原创 Leetcode前400题摘选

Majority Element IIhttps://blog.csdn.net/zxc120389574/article/details/106100798ZigZag Conversionhttps://blog.csdn.net/zxc120389574/article/details/105367578Factorial Trailing Zeroeshttps://blog.csdn.net/zxc120389574/article/details/106022546Word Lad.

2020-10-28 22:56:01 188

原创 Conda错误:Solving environment: failed with current_repodata.json

我用下面这个方法解决了:https://www.cnblogs.com/Yefudaling/p/12422372.html

2020-09-11 20:09:32 15747 2

原创 录制Gif动画的软件-ScreenToGif

ScreenToGif,傻瓜操作,很强https://www.screentogif.com/

2020-07-28 19:45:47 118

原创 【Linux】cannot open shared object file: No such file or directory解决方法

问题:完整错误信息:./mgw: error while loading shared libraries: libxxx.so: cannot open shared object file: No such file or directory方法:直接在运行./mgw的.sh脚本中添加下面语句即可:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/your/path参考:https://blog.csdn.net/qc530167365/article/de

2020-07-27 21:06:38 672 1

原创 GitHub上最受欢迎的CI工具

Travis CIhttps://travis-ci.org/参考:https://www.jianshu.com/p/64fc783568b1

2020-07-26 18:04:58 263

转载 【Windows】递归搜索指定目录及其子目录下所有文件内容

https://blog.csdn.net/shenshen211/article/details/80050865

2020-07-15 15:48:58 1263

原创 【Python】常用文件操作

对文件内容操作:file= open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)file.read([size]) #size为读取的长度,以byte为单位file.readline([size]) #读一行,如果定义了size,有可能返回的只是一行的一部分file.readlines([size]) #把文件每一行作为一个list的一个成员

2020-07-05 21:37:54 170

原创 【Python】解压zip文件

递归遍历并解压zip中所有.doc,.docx和.pdf:def unzip_report(zip_name): with zipfile.ZipFile(zip_name,'r') as z: names = z.namelist() print (type(names)) for name in names: # 遍历每个文件名 #name = name.encode("cp437").decod

2020-07-05 20:29:33 2527

原创 【Linux】编译C++文件命令

gcc -o test test.cpp

2020-06-28 10:06:27 129

原创 vim配置文件.vimrc——设置tab为4格

在用户home目录下创建.vimrc文件,然后输入以下配置:set tabstop=4set sw=4 set noexpandtabset autoindent

2020-06-28 09:58:59 639

原创 我的第一个Makefile文件

$(warning "outer0")TMP=./tmp/BIN=./bin/test=testall: test2 # 默认入口,然后按顺序执行。注:执行完全局的命令之后,才会转到此处执行。有all的时候,会严格按照all中的顺序执行;没有all的时候,执行第一个命令块(第一个命令快是test3)。$(warning "outer")test3: $(warning "test3")test2: $(warning "test2")test: $(w

2020-06-17 16:43:37 132

原创 Linux常用指令(持续更新中ing)

创建用户:useradd -d /home/username -m username # -d 用户目录,-m 用户名passwd username # 设置密码

2020-06-11 15:40:26 153

原创 将Markdown格式文件转换为PDF文件

利用Windows版本的Typora即可。参考:https://www.zhihu.com/question/20849824

2020-06-10 22:14:35 201

原创 【leetcode】393. UTF-8 Validation

题目:思路:规律很明显,比较简单。代码实现:自己实现的代码,有点繁琐:class Solution {public: int type(int i){ int mask = 128; while (mask & i){ mask >>= 1; } if (mask == 128){ return 0; }else if

2020-05-31 01:33:28 117

原创 【leetcode】392. Is Subsequence

题目:Given a string s and a string t, check if s is subsequence of t.A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remain

2020-05-31 00:55:25 130

原创 【leetcode】390. Elimination Game

题目:There is a list of sorted integers from 1 to n. Starting from left to right, remove the first number and every other number afterward until you reach the end of the list.Repeat the previous step again, but this time from right to left, remove the righ

2020-05-31 00:39:49 176

原创 【leetcode】389. Find the Difference

题目:Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was added in t.思路:ans初始值为0,然后对s和t的所有元素进行异或操作后就是答案。代码实现:c

2020-05-31 00:24:29 135

原创 【leetcode】388. Longest Absolute File Path

题目:思路:将"\n"将整个string分割成strings数组,数组中每一个元素都是一个folder名字或file名字,决定其所在层级的是名字最前面的"\t"的数量,"\t"的数量加1就是其所在的层级。剩下的就是利用stack不断地进行探索与回溯就可以了。代码实现:class Solution {public: void splitString(vector<string>& strings, const string& org_string, cons

2020-05-31 00:19:18 182

原创 Google 开源项目风格指南——C++ 风格指南

Google 开源项目风格指南——C++ 风格指南

2020-05-30 12:48:35 233

原创 【leetcode】387. First Unique Character in a String

题目:Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.思路:扫描两遍数组即可。代码实现:class Solution {public: int firstUniqChar(string s) { vector<int> hash(26, 0);

2020-05-30 00:27:00 121

原创 【leetcode】386. Lexicographical Numbers

题目:思路:抄不懂。手算一下+脑补一下。代码实现:class Solution {public: vector<int> lexicalOrder(int n) { vector<int> res(n); int cur = 1; for (int i = 0; i < n; ++i){ res[i] = cur; if (cur * 10

2020-05-30 00:20:25 116

原创 【leetcode】385. Mini Parser

题目:思路:‘[’ 新建NestedInteger,’,‘跳过,’]’ 出栈并建立好前后关联。代码实现:class Solution {public: NestedInteger deserialize(string s) { stack<NestedInteger*> my_stack; my_stack.push(new NestedInteger()); for (int i = 0; i < s.size();

2020-05-29 23:34:37 160

空空如也

空空如也

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

TA关注的人

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