说明:当前基本以windows版本下的使用介绍,from udacity
熟悉基本指令:Windows-command-line-basics 目录切换: cd \ ; F: ; cd … ; dir (相当于ls) path
pip源更新
pip 后加参数 -i https://pypi.tuna.tsinghua.edu.cn/simple 例:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xxxx Linux下:修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下: [global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple windows下:直接在user目录中创建一个pip目录,如:C:\Users\xxxx\pip,新建文件pip.ini [global] index-url = https://pypi.tuna.tsinghua.edu.cn/simpleconda 换源:
#conda 换源: 相当于修改~/.condarc文件 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes ## .condarc文件中的 - defaults那行去掉 不然conda info可以查看到会加载更多官网的源~/.condarc
channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ show_channel_urls: true[cloud_lesson.yaml](#### cloud_lesson.xml) conda env create -f cloud_lesson.yaml
conda环境相关 conda create -n env_name pkg1 pkg2(创建安装有pkg1 pkg2的env_name环境) conda create -n py3 python=3.5 conda env lsit 进入环境:activate py3 进入环境后,你会在终端提示符中看到环境名称,它类似于 (my_env) ~ $。环境中只安装了几个默认的包,以及你在创建它时安装的包。 conda list 继续安装: conda install pkg_name2 退出原环境: deactivate py3####2.3 保存与加载环境 conda env export > environment_1.yaml 利用环境文件创建新环境: conda env create -f environment_1.yaml conda env list conda env remove -n env_name
个人proect 最好采用创建环境的方式, conda共享或用pip freeze的方式。 conda详细手册
py2与py3中print区别
#py2 print "Hello", "world!" #py3 print("Hello", "world!") #Python 2.6+ 导入函数print_function from __future__ import print_function print("Hello", "world!")##3 Jupyter notebook Jupyter notebook 是一种 Web 应用,能让用户将说明文本、数学方程、代码和可视化内容全部组合到一个易于共享的文档中。 How IPython and Jupyter Notebook work
####3.1 安装jupyter notebook
conda install jupyter notebook pip install jupyter notebook (或)C:\Users\yhzhao.conda
####3.2 启动notebook服务器 jupyter notebook 服务器地址 http://localhost:8888 jupyter notebook password 创建服务器密码 终端中两次 Ctrl + C,可以关闭整个服务器。记得关闭 noteboo前保存相应内容
####3.3 Magic 关键字 嵌入jupyter的命令行中 使用 %matplotlib 将 matplotlib 设置为以交互方式在 notebook 中工作。Magic 命令的前面带有一个或两个百分号(% 或 %%),分别对应行 Magic 命令和单元格 Magic 命令。
%%timeit %matplotlib %config InlineBackend.figure_format = 'retina' 来呈现分辨率较高的图像。 %pdb 开启交互式调试器more
####3.4 Python·Jupyter Notebook各种使用方法记录·持续更新
PythonJupyter Notebook各种使用方法记录持续更新 一 Jupyter NoteBook的安装 1 新版本Anaconda自带Jupyter 2 老版本Anacodna需自己安装Jupyter 二 更改Jupyter notebook的工作空间 1 Jupyter的工作空间在哪里指定 2 如何找到该配置文件 三Jupyter的各种快捷键 四Jupyter Notebook如何导入代码 1 将本地的py文件load到jupyter的一个cell中 2 从网络load代码到jupyter 五Jupyter运行python文件 六Jupyter一些其他琐碎用法 1 jupyter的cell可以作为unix command使用 2 Magic functions 3 获取current working directory 4 使用Matplotlib绘图 七Jupyter中的Markdown 1 在jupyter中设置link需要设置两部分 2 为Jupyter Notebook添加目录功能(为Jupyter Notebook添加目录) [https://zhuanlan.zhihu.com/p/24029578?refer=learnMLb/jupyter_contrib_nbextensions]
##4 markdown的使用说明
#####4.1 标题’#’
# Header 1 ## Header 2 ### Header 3#####4.2 链接 []和() [kint_zhao](http://blog.csdn.net/zyh821351004) kint_zhao
#####4.3 强调效果(* 或 _) 对于斜体,在文本两侧加上一个星号或下划线 粗体文本使用两个符号 _gelato_ 或 *gelato*会呈现为 gelato 或 gelato 。 **aardvark** 或 __aardvark__会呈现为aardvark 或 aardvark 。
#####4.4 代码 可以通过两种不同的方式显示代码,一种是与文本内联,另一种是将代码块与文本分离。要将代码变为内联格式,请在文本两侧加上反撇号。 ` ````
要创建代码块,请另起一行并用三个反撇号将文本包起来:``` 或者将代码块的每一行都缩进四个空格。
import requests response = requests.get(‘https://www.udacity.com’)
#####4.5 数学表达式 latex入门指导文档 在 Markdown 单元格中,可以使用 LaTeX 符号创建数学表达式。notebook 使用 MathJax 将 LaTeX 符号呈现为数学符号。要启动数学模式,请在 LaTeX 符号两侧加上美元符号$ $,以创建内联的数学表达式。对于数学符号块,请使用两个美元符号$$ $$:
y = m x + b y=mx+b y=mx+b P ( A ∣ B ) = P ( B ∣ A ) P ( A ) P ( B ) P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B)} P(A∣B)=P(B)P(B∣A)P(A)
e 2 x e^2x e2x e 2 x e^{2x} e2x 10 C 5 _{10}C_5 10C5
2 π \sqrt{2\pi} 2π $\alpha, \beta, \gamma$ : α, β, γ.
$\Phi, \Lambda, \Gamma$ : Φ, Λ, Γ. Note that uppercase beta is just B, so there is no B \Beta B.
$ \times,\pm, \cup, \oplus$ : ×, ±, ∪, ⊕
$ \sin, \cosh, \arctan$ : sinsin, coshcosh, arctanarctan.
$ \leq, \geq, \approx, \neq$: ≤, ≥, ≈, ≠
$ \cdots, \ldots, \ddots$: ⋯, …, ⋱
$ \infty, \nabla, \partial$: ∞, ∇, ∂
Put a hat: : $\hat x$ $\widehat{abs}$ x ^ \hat x x^ a b s ^ \widehat{abs} abs means : $\bar x$ $\overline{abs}$ x ˉ \bar x xˉ a b s ‾ \overline{abs} abs derivatives : $\dot x$ $\ddot x$ x ˙ \dot x x˙ x ¨ \ddot x x¨ Arrows: : $\vec{x}$ ,$\overrightarrow{xy}$ x ⃗ \vec{x} x , x y → \overrightarrow{xy} xy
$z = (\frac{dx}{dy})^{1/3}$ z = ( d x d y ) 1 / 3 z = (\frac{dx}{dy})^{1/3} z=(dydx)1/3
make brackets stretchy, use \left and \right, $$z = \left(\frac{dx}{dy}\right)^{1/3}$$ z = ( d x d y ) 1 / 3 z = \left(\frac{dx}{dy}\right)^{1/3} z=(dydx)1/3
Vertical lines with | or \vert ∣ x ∣ |x| ∣x∣ ∣ x \vert x ∣x $P(A\mid B)$ P ( A ∣ B ) P(A\mid B) P(A∣B)
Angle brackets: $\langle \phi \mid \psi \rangle$ ⟨ ϕ ∣ ψ ⟩ \langle \phi \mid \psi \rangle ⟨ϕ∣ψ⟩ gives ⟨ϕ∣ψ⟩
Group brackets for matrices (also, hey, here’s how to make a matrix): KaTeX parse error: Undefined control sequence: \matrix at position 14: \left\lgroup \̲m̲a̲t̲r̲i̲x̲{a & b\cr c & d…
$\int f(x)\,dx$ ∫ f ( x ) d x \int f(x)\,dx ∫f(x)dx gives
KaTeX parse error: Undefined control sequence: \Tiny at position 131: … \rm\tiny tiny \̲T̲i̲n̲y̲ ̲Tiny \small sma…
For larger spaces, use a n d \quad and \qquad and.
对齐 $$ a_1 = b_1 + c_1 \\ a_2 = b_2 + c_2 + d_2 $$ a 1 = b 1 + c 1 a 2 = b 2 + c 2 + d 2 a_1 = b_1 + c_1 \\ a_2 = b_2 + c_2 + d_2 a1=b1+c1a2=b2+c2+d2
KaTeX parse error: No such environment: align at position 8: \begin{̲a̲l̲i̲g̲n̲}̲ a_1 & = b_1 + …
` KaTeX parse error: No such environment: align at position 8: \begin{̲a̲l̲i̲g̲n̲}̲ a_1 & = b_1 + …
$$y=mx+b$$ $$P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B)}$$ $e^2x$ $e^{2x}$ $_{10}C_5$ $\sqrt{2\pi}$ $\alpha, \beta, \gamma$ : α, β, γ. $\Phi, \Lambda, \Gamma$ : Φ, Λ, Γ. Note that uppercase beta is just B, so there is no $\Beta$. $ \times,\pm, \cup, \oplus$ : ×, ±, ∪, ⊕ $ \sin, \cosh, \arctan$ : sinsin, coshcosh, arctanarctan. $ \leq, \geq, \approx, \neq$ : ≤, ≥, ≈, ≠ $ \cdots, \ldots, \ddots$ : ⋯, …, ⋱ $ \infty, \nabla, \partial$ : ∞, ∇, ∂ Put a hat: :$ \hat x $ $ \widehat{abs}$ means :$ \bar x$ $ \overline{abs}$ derivatives :$ \dot x$ $ \ddot x$ Arrows: :$ \vec{x}$ ,$ \overrightarrow{xy} $ $z = (\frac{dx}{dy})^{1/3}$ make brackets stretchy, use \left and \right, $$z = \left(\frac{dx}{dy}\right)^{1/3}$$ Vertical lines with | or \vert $|x|$ $\vert x$ $P(A\mid B)$ Angle brackets: $\langle \phi \mid \psi \rangle$ gives ⟨ϕ∣ψ⟩ Group brackets for matrices (also, hey, here's how to make a matrix): $\left\lgroup \matrix{a & b\cr c & d} \right\rgroup$ $\int f(x)\,dx$ gives $$ For non-italicized Roman text, use \textrm{Roman} or \rm Roman: RomanRoman or RomanRoman To change the font size: \rm\tiny tiny \Tiny Tiny \small small \normalsize normal \large lg \Large Lg \LARGE LG \huge hg \Huge Hg $$ For larger spaces, use $\quad and \qquad$. 对齐 $$ a_1 = b_1 + c_1 \\ a_2 = b_2 + c_2 + d_2 $$ $$ \begin{align} a_1 & = b_1 + c_1 \\ a_2 & = b_2 + c_2 + d_2 \end{align} $$`
y = m x + b y=mx+b y=mx+b P ( A ∣ B ) = P ( B ∣ A ) P ( A ) P ( B ) P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B)} P(A∣B)=P(B)P(B∣A)P(A)
e 2 x e^2x e2x e 2 x e^{2x} e2x 10 C 5 _{10}C_5 10C5
2 π \sqrt{2\pi} 2π α , β , γ \alpha, \beta, \gamma α,β,γ : α, β, γ.
Φ , Λ , Γ \Phi, \Lambda, \Gamma Φ,Λ,Γ : Φ, Λ, Γ. Note that uppercase beta is just B, so there is no B \Beta B.
$ \times,\pm, \cup, \oplus$ : ×, ±, ∪, ⊕
$ \sin, \cosh, \arctan$ : sinsin, coshcosh, arctanarctan.
$ \leq, \geq, \approx, \neq$ : ≤, ≥, ≈, ≠
$ \cdots, \ldots, \ddots$ : ⋯, …, ⋱
$ \infty, \nabla, \partial$ : ∞, ∇, ∂
Put a hat: 😒 \hat x $ $ \widehat{abs}$ means 😒 \bar x$ $ \overline{abs}$ derivatives 😒 \dot x$ $ \ddot x$ Arrows: 😒 \vec{x}$ ,$ \overrightarrow{xy} $
z = ( d x d y ) 1 / 3 z = (\frac{dx}{dy})^{1/3} z=(dydx)1/3
make brackets stretchy, use \left and \right, z = ( d x d y ) 1 / 3 z = \left(\frac{dx}{dy}\right)^{1/3} z=(dydx)1/3
Vertical lines with | or \vert ∣ x ∣ |x| ∣x∣ ∣ x \vert x ∣x P ( A ∣ B ) P(A\mid B) P(A∣B)
Angle brackets: ⟨ ϕ ∣ ψ ⟩ \langle \phi \mid \psi \rangle ⟨ϕ∣ψ⟩ gives ⟨ϕ∣ψ⟩
Group brackets for matrices (also, hey, here’s how to make a matrix): KaTeX parse error: Undefined control sequence: \matrix at position 14: \left\lgroup \̲m̲a̲t̲r̲i̲x̲{a & b\cr c & d…
∫ f ( x ) d x \int f(x)\,dx ∫f(x)dx gives
KaTeX parse error: Undefined control sequence: \Tiny at position 131: … \rm\tiny tiny \̲T̲i̲n̲y̲ ̲Tiny \small sma…
For larger spaces, use a n d \quad and \qquad and.
对齐 a 1 = b 1 + c 1 a 2 = b 2 + c 2 + d 2 a_1 = b_1 + c_1 \\ a_2 = b_2 + c_2 + d_2 a1=b1+c1a2=b2+c2+d2
KaTeX parse error: No such environment: align at position 8: \begin{̲a̲l̲i̲g̲n̲}̲ a_1 & = b_1 + …