❤Thanksgiving❤

随笔

Serialization and Deserialization

序列化与反序列化 Serialization:Data Structure/Object --> Binary String Deserialization:Binary String --> Data Structure/Object Goals:Cross-platform Communication、Persistent Storage and More Python中对象的序列化与反序列化 pickle module pickle 仅可用于 Python,pickle所使用的数据流格式仅可用于 Python pickle 模块可以将复杂对象转换为字节流,也可以将字节流转换为具有相同内部结构的对象。 可被pickling和unpickling的对象:https://docs.python.org/zh-cn/3/library/pickle.html#what-can-be-pickled-and-unpickled pickle提供了优秀的方法方便我们对对象进行pickling(封存)和unpickling(解封)

Python

map-filter-reduce

听说函数式编程很⑥,咱也不知道,咱也不晓得,还没实际用过。emmm。。。。,先mark下Python中和函数式编程有关的部分功能先,又开始水了,立个flag🚩:慢慢完善 map 先看下Python官方文档的说法 map(function, iterable, …),返回一个将 function 应用于 iterable 中每一项并输出其结果的迭代器。 如果传入了额外的 iterable 参数,function 必须接受相同个数的实参并被应用于从所有可迭代对象中并行获取的项。 见识一下 123456789101112>>> def cook(something):... if something == "cow":... return "hamburger"... elif something == "tomato":... return "chips"... elif something == "chicken":... return "ddrumstick"... elif something == "corn":... return "popcorn"...>>> list(map(cook, ["cow", "tomato", "chicken", "corn"]))['hamburger', 'chips', 'ddrumstick', 'popcorn']

函数式编程

git clone后如何checkout到remote branch

what/why 通常情况使用git clone github_repository_address下载下来的仓库使用git branch查看当前所有分支时只能看到master分支,但是想要切换到其他分支进行工作怎么办❓ 其实使用git clone...

Git

使用Microsoft Edge Beta将网页变成应用

今天无聊的我打开了装了很久都没用的Microsoft Edge Beta,一波乱戳,惊讶的发现Microsoft Edge Beta居然有将网页打包为应用的功能😂 B站也有PC"客户端"了,真香😂

随笔

简单感受下Python内置数据类型常用操作的性能

生成一个列表的几种方式的性能对比 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152# -*- coding: utf-8 -*-from timeit import Timerimport matplotlib.pyplot as plt# 列表常用操作性能测试# 迭代 + '+'def test1(): l = [] for i in range(1000): l = l + [i]# 迭代 + appenddef test2(): l = [] for i in range(1000): l.append(i)# 列表生成式def test3(): l = [i for i in range(1000)]# list构造函数 + rangedef test4(): l = list(range(1000))t1 = Timer("test1()", "from __main__ import test1")# print("concat %f seconds" % t1.timeit(number=1000))t2 = Timer("test2()", "from __main__ import test2")# print("concat %f seconds" % t2.timeit(number=1000))t3 = Timer("test3()", "from __main__ import test3")# print("concat %f seconds" % t3.timeit(number=1000))t4 = Timer("test4()", "from __main__ import test4")# print("concat %f seconds" % t4.timeit(number=1000))result = [t1.timeit(1000), t2.timeit(1000), t3.timeit(1000), t4.timeit(1000)]method = ["for+ '+'", "for + append", "list comprehension", "list + range"]plt.bar(method, result, color='rgby')# plt.legend('concat time')# print(zip(method, result))for x,y in zip(method, result): plt.text(x, y, "%fs" % y)plt.show()

Python

Python 环境管理与项目依赖管理

个人简单记录下 virtualenv + pip virtualenv是一个用于创建"隔离的ython运行环境"的工具,Docs pip是Python的包管理工具,Docs 1234567891011121314# 安装virtualenvpip install virtualenv# -------------------------------- ## 虚拟环境的创建与使用# 1、在当前工程目录下使用virtualenv创建一套独立的Python运行环境virtualenv venv # 环境名为venv(自由定义)# 2、cd 到创建好的虚拟环境的Scripts目录,执行如下命令可激活或者退出虚拟环境activate # 激活,激活后命令提示符会变成当前工程目录Python环境名deactivate # 退出# 3、激活虚拟环境后可使用pip为当前项目安装依赖,example:pip install numpy# 4、使用pip freeze > requirements.txt 可导出项目依赖到requirements.txt中# 为项目创建一个新的、干净的环境时,可使用 pip install -r requiremen.txt 为项目安装依赖

Python

docker学习笔记

Play With Docker一个免费使用的基于web界面的Docker环境 常用docker命令 可使用docker COMMAND --help查看命令的用法 Docker镜像相关 1、docker image pull:用于下载镜像,镜像从远程镜像仓库服务的仓库中下载,默认从Docker Hub的仓库中拉取 1234# 格式:docker pull [OPTIONS] NAME[:TAG|@DIGEST]# 说明:如果给出tag,一般拉取latest,name一般为username/repository,digest为镜像摘要可不给出docker image pull ubuntu:latest# 这个拉取标签为latest的ubuntu官方镜像,latest: Pulling from library/ubuntu,latest不一定是最新镜像

docker

几个不错的Jupyter Notebook云端展示平台

jupyter nbviewer URL:https://nbviewer.jupyter.org/ 结合Github的示例用法:https://nbviewer.jupyter.org/github/ + <用户名或者用户名/存放ipynb文件的仓库或者Gist ID> 例如:https://nbviewer.jupyter.org/github/yeshan333/JupyterNotebook-Show-sample

Python

pdb && cProfile

pdb https://docs.python.org/zh-cn/3.7/library/pdb.html#module-pdb 使用方式 1、在命令行下直接运行调试 1python -m pdb test.py 2、在需要被调试的代码中添加import pdb、pdb.set_trace()再运行代码进行调试

Python
1789101117