怎么样在你的Android手机上配置 Python 环境?
<h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">举荐</span>学习</h1><strong style="color: blue;"><a style="color: black;">金三即过,这300道python高频面试都没刷,银四怎么闯?</a> </strong>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/ae696e6bc8e94d0cab0d26172f4707e6~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723894245&x-signature=7Ap4uv%2BO6%2BwWXBEGwlT0GogF74k%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">本文旨在讲解<span style="color: black;">怎样</span>在Android平板或手机上搭建Python<span style="color: black;">研发</span>环境,<span style="color: black;">帮忙</span>Python初学者有效利用碎片化时间进行学习,从而达到良好的学习效果。</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">针对</span>大部分初学Python的人<span style="color: black;">来讲</span>,<span style="color: black;">因为</span>工作、生活等<span style="color: black;">原因</span>常常<span style="color: black;">没法</span>进行连贯、系统的学习。初学者为了利用上下班通勤等碎片化时间进行学习,<span style="color: black;">一般</span>会在平板上观看学习视频并做记录。虽然这种<span style="color: black;">办法</span>很好,但效果还是不如边学边练来得好。</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">因此呢</span>,你<span style="color: black;">必须</span>的是这个:</span></span></p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/7b86762a84e544ee9dea6e6af9cbfb31~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723894245&x-signature=H5szzHGpNAEeWcPIhBSM5iD%2FQqY%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">不多说,让<span style="color: black;">咱们</span><span style="color: black;">起始</span>吧!</span></span></p>
<h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">1、</span>Termux安装与配置</h1>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">1. 系统<span style="color: black;">需求</span></h1><span style="color: black;"><span style="color: black;">Android 7.0以上的平板或手机。<span style="color: black;">这儿</span><span style="color: black;">意见</span><span style="color: black;">运用</span>兼顾了便携性和屏幕尺寸的8寸平板。</span></span><span style="color: black;"><span style="color: black;">2G以上可用空间。<span style="color: black;">因为</span><span style="color: black;">必须</span>安装<span style="color: black;">各样</span>软件包,对存储空间的消耗还是比<span style="color: black;">很强</span>的。</span></span>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">2. Termux安装</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">在安装Termux前,<span style="color: black;">必须</span><span style="color: black;">认识</span>一下什么是Termux。</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">Termux 是一款支持 Linux 环境的 Android 终端模拟器APP。你无需对手机进行root或额外设置<span style="color: black;">就可</span><span style="color: black;">运用</span>。这款APP会在手机中自动安装一个最小化基本系统,并支持<span style="color: black;">运用</span> APT 包管理工具安装软件。</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">日前</span>Termux官网(</span><span style="color: black;"><span style="color: black;">https://termux.com/</span></span><span style="color: black;">)<span style="color: black;">意见</span><span style="color: black;">运用</span>F-Droid进行安装,<span style="color: black;">再也不</span>支持<span style="color: black;">经过</span>Google Play进行安装。</span></span></p><span style="color: black;"><span style="color: black;">主程序</span><span style="color: black;"><span style="color: black;">Termux</span></span><span style="color: black;">下载<span style="color: black;">位置</span>:</span></span><span style="color: black;">https</span>:<span style="color: black;">//f-droid.org/repo/com.termux_106.apk</span><span style="color: black;"><span style="color: black;">美化工具</span><span style="color: black;"><span style="color: black;">Termux:Styling</span></span><span style="color: black;">下载<span style="color: black;">位置</span>:</span></span><span style="color: black;">https</span>:<span style="color: black;">//f-droid.org/repo/com.termux.styling_29.apk</span>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">3. Termux基本操作</h1><span style="color: black;"><span style="color: black;">快捷键</span></span>Ctrl + A -> 将光标移动到行首
Ctrl + E -> 将光标移动到行尾
Ctrl + C -> 中止当前进程
Ctrl + D -> 注销终端会话
Ctrl + K -> 从光标删除到行尾
Ctrl + U -> 从光标删除到行首
Ctrl + L -> 清除终端
Ctrl + Z -> 挂起(发送SIGTSTP到)当前进程
音量加 + E -> Esc键
音量加 + T -> Tab键
音量加 +<span style="color: black;">1</span> -> F1(音量<span style="color: black;">增多</span> + <span style="color: black;">2</span> → F2…以此类推)
音量加 + <span style="color: black;">0</span>-> F10
音量加 + B -> Alt + B,<span style="color: black;">运用</span>readline时返回一个单词
音量加 + F -> Alt + F,<span style="color: black;">运用</span>readline时转发一个单词
音量加 + X -> Alt+X
音量加 + W -> 向上箭头键
音量加 + A -> 向左箭头键
音量加 + S -> 向下箭头键
音量加 + D -> 向右箭头键
音量加 + L -> | (管道字符)
音量加 + H -> 〜(<span style="color: black;">浪花</span>号字符)
音量加 + U -> _ (下划线字符)
音量加 + P -> 上一页
音量加 + N -> 下一页
音量加 + . -> Ctrl + \(SIGQUIT)
音量加 + V -> <span style="color: black;">表示</span>音量<span style="color: black;">掌控</span>
音量加 + Q -> 切换<span style="color: black;">表示</span>的功能键视
音量加 + K -> 切换<span style="color: black;">表示</span>的功能键视图<h1 style="color: black; text-align: left; margin-bottom: 10px;">4. 修改软件源</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">安装完Termux后,<span style="color: black;">运用</span>如下命令自动替换官方源为清华镜像源:</span></span></p>sed -i <span style="color: black;">s@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main@</span> $PREFIX/etc/apt/sources.<span style="color: black;">list</span>
sed -i <span style="color: black;">s@^\(deb.*games stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/game-packages-24 games stable@</span> $PREFIX/etc/apt/sources.<span style="color: black;">list</span>.d/game.<span style="color: black;">list</span>
sed -i <span style="color: black;">s@^\(deb.*science stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/science-packages-24 science stable@</span> $PREFIX/etc/apt/sources.<span style="color: black;">list</span>.d/science.<span style="color: black;">list</span>
apt update && apt upgrade<h1 style="color: black; text-align: left; margin-bottom: 10px;">5. 安装基本组件</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">在配置Python<span style="color: black;">研发</span>环境前,<span style="color: black;">咱们</span>还<span style="color: black;">必须</span><span style="color: black;">运用</span>如下命令安装<span style="color: black;">有些</span>基本软件包:</span></span></p>p<span style="color: black;">公斤</span> <span style="color: black;">install</span> -y zsh curl wget <span style="color: black;">build</span>-essential
p<span style="color: black;">公斤</span> <span style="color: black;">install</span> -y git python nodejs-lts perl ipython
p<span style="color: black;">公斤</span> <span style="color: black;">install</span> -y neovim lazygit ranger fzf<h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">2、</span>终端配置</h1>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">1. Shell配置</h1><span style="color: black;"><span style="color: black;">安装</span><span style="color: black;"><span style="color: black;">oh-my-zsh</span></span></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">Shell的类型有<span style="color: black;">非常多</span>种,Termux下默认<span style="color: black;">运用</span>的是</span><span style="color: black;"><span style="color: black;">bash</span></span><span style="color: black;">,<span style="color: black;">这儿</span><span style="color: black;">运用</span>功能更强大的</span><span style="color: black;"><span style="color: black;">zsh</span></span><span style="color: black;">来代替</span><span style="color: black;"><span style="color: black;">bash</span></span><span style="color: black;">。为了让初学者更好地<span style="color: black;">运用</span></span><span style="color: black;"><span style="color: black;">zsh</span></span><span style="color: black;">,<span style="color: black;">必须</span>先安装高档大气上档次,狂拽炫酷吊炸天的</span><span style="color: black;"><span style="color: black;">oh-my-zsh</span></span><span style="color: black;">。</span></span></p>sh -c <span style="color: black;">"<span style="color: black;">$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)</span>"</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">安装过程中,会提示<span style="color: black;">是不是</span>切换shell为</span><span style="color: black;"><span style="color: black;">zsh</span></span><span style="color: black;">,输入</span><span style="color: black;"><span style="color: black;">回车</span></span><span style="color: black;">或</span><span style="color: black;"><span style="color: black;">Y</span></span><span style="color: black;"><span style="color: black;">就可</span>。</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">另外</span>,还<span style="color: black;">必须</span>安装</span><span style="color: black;"><span style="color: black;">zsh-autosuggestions</span></span><span style="color: black;">插件,用于自动补全:</span></span></p><span style="color: black;">git</span>clone https://github.com/zsh-users/zsh-autosuggestions<span style="color: black;">${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}</span>/plugins/zsh-autosuggestions<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">oh-my-zsh</span></span><span style="color: black;"><span style="color: black;">必须</span><span style="color: black;">运用</span></span><span style="color: black;"><span style="color: black;">nano</span></span><span style="color: black;">、</span><span style="color: black;"><span style="color: black;">neovim</span></span><span style="color: black;">等终端编辑器修改</span><span style="color: black;"><span style="color: black;">.zshrc</span></span><span style="color: black;">文件来进行配置,在</span><span style="color: black;"><span style="color: black;">plugins</span></span><span style="color: black;">部分添加插件支持:</span></span></p>plugins=(
git
python
colorize
zsh-interactive-cd
zsh-navigation-tools
zsh-autosuggestions
)<h1 style="color: black; text-align: left; margin-bottom: 10px;">2. 主题美化</h1>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">2.1 配色与字体</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">长按屏幕,点击</span><span style="color: black;"><span style="color: black;">More</span></span><span style="color: black;">,<span style="color: black;">选取</span></span><span style="color: black;"><span style="color: black;">Style</span></span><span style="color: black;"><span style="color: black;">能够</span><span style="color: black;">选取</span>配色和字体,<span style="color: black;">举荐</span><span style="color: black;">运用</span></span><span style="color: black;"><span style="color: black;">Neon</span></span><span style="color: black;">配色和</span><span style="color: black;"><span style="color: black;">JetBrains Mono</span></span><span style="color: black;">字体,<span style="color: black;">亦</span><span style="color: black;">能够</span><span style="color: black;">经过</span>修改</span><span style="color: black;"><span style="color: black;">~/.termux/</span></span><span style="color: black;">目录下的</span><span style="color: black;"><span style="color: black;">colors.properties</span></span><span style="color: black;">和</span><span style="color: black;"><span style="color: black;">font.ttf</span></span><span style="color: black;">文件进行自定义。</span></span></p>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">2.2 主题配置</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">接下来安装</span><span style="color: black;"><span style="color: black;">powerlevel10k</span></span><span style="color: black;">的主题:</span></span></p><span style="color: black;"><span style="color: black;">安装</span></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">输入如下命令下载</span><span style="color: black;"><span style="color: black;">powerlevel10k</span></span><span style="color: black;">:</span></span></p><span style="color: black;">git</span> clone --depth=<span style="color: black;">1</span> https://gitee.com/romkatv/powerlevel10k.git <span style="color: black;">${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}</span>/themes/powerlevel10k<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">修改</span><span style="color: black;"><span style="color: black;">.zshrc</span></span><span style="color: black;">文件,将</span><span style="color: black;"><span style="color: black;">ZSH_THEME="robbyrussell"</span></span><span style="color: black;">改为</span><span style="color: black;"><span style="color: black;">ZSH_THEME="powerlevel10k/powerlevel10k"</span></span><span style="color: black;">。</span></span></p><span style="color: black;"><span style="color: black;">配置</span></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">重新打开Termux,输入</span><span style="color: black;"><span style="color: black;">p10k configure</span></span><span style="color: black;">进入</span><span style="color: black;"><span style="color: black;">powerlevel10k</span></span><span style="color: black;">的配置界面。<span style="color: black;">第1</span>次会自动下载默认字体,安装后会自动退出,重新打开Termux<span style="color: black;">就可</span>。</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">能够</span><span style="color: black;">按照</span>配置向导的提示,定制适合自己风格的终端界面。</span></span></p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/58729db8ea09468b8c902833cf2e3afb~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723894245&x-signature=LvwP65m0kcpbnS1uObMLaPxvPK8%3D" style="width: 50%; margin-bottom: 20px;"></div>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">3. 启用vi模式(可选)</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">Termux命令行中修改<span style="color: black;">已然</span>输入的命令比较麻烦。<span style="color: black;">经过</span>开启</span><span style="color: black;"><span style="color: black;">vi</span></span><span style="color: black;">模式,用户<span style="color: black;">能够</span>像在</span><span style="color: black;"><span style="color: black;">vi</span></span><span style="color: black;">编辑器里<span style="color: black;">同样</span>进行操作。<span style="color: black;">针对</span></span><span style="color: black;"><span style="color: black;">vi</span></span><span style="color: black;">用户<span style="color: black;">来讲</span>,进入这种模式后,编辑和修改命令就<span style="color: black;">显出</span><span style="color: black;">非常</span>得心应手了。</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">运用</span></span><span style="color: black;"><span style="color: black;">nano</span></span><span style="color: black;">、</span><span style="color: black;"><span style="color: black;">neovim</span></span><span style="color: black;">等终端编辑器修改</span><span style="color: black;"><span style="color: black;">.zshrc</span></span><span style="color: black;">文件来进行配置,在</span><span style="color: black;"><span style="color: black;">plugins</span></span><span style="color: black;">部分添加</span><span style="color: black;"><span style="color: black;">vi-mode</span></span><span style="color: black;">项,开启</span><span style="color: black;"><span style="color: black;">vi</span></span><span style="color: black;">模式。在命令行状态下,按</span><span style="color: black;"><span style="color: black;">Esc</span></span><span style="color: black;">键,<span style="color: black;">就可</span>进入</span><span style="color: black;"><span style="color: black;">vi</span></span><span style="color: black;">模式的</span><span style="color: black;"><span style="color: black;">普通模式</span></span><span style="color: black;">。</span></span></p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/4dd6bbca04e8453db5fa0060dbaf9fd8~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723894245&x-signature=XB2SJwMvrG0iRyAtJQJsV420J7w%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">不外</span>在默认的vi模式存在按键bug,<span style="color: black;">必须</span>在</span><span style="color: black;"><span style="color: black;">.zshrc</span></span><span style="color: black;">文件最后添加如下配置:</span></span></p><span style="color: black;"># Better searching in command mode</span>
<span style="color: black;">bindkey</span> -M vicmd <span style="color: black;">?</span> <span style="color: black;">history</span>-incremental-search-backward
<span style="color: black;">bindkey</span> -M vicmd <span style="color: black;">/</span> <span style="color: black;">history</span>-incremental-search-forward
<span style="color: black;"># Beginning search with arrow keys</span>
<span style="color: black;">bindkey</span> <span style="color: black;">"\033[1~"</span> beginning-of-line
<span style="color: black;">bindkey</span> <span style="color: black;">"\033[4~"</span> end-of-line
<span style="color: black;">bindkey</span> <span style="color: black;">^[[3~</span> delete-char
<span style="color: black;">bindkey</span> <span style="color: black;">"^[OA"</span> up-line-or-beginning-search
<span style="color: black;">bindkey</span> <span style="color: black;">"^[OB"</span> down-line-or-beginning-search
<span style="color: black;">bindkey</span> -M vicmd <span style="color: black;">"k"</span>up-line-or-beginning-search<span style="color: black;">bindkey</span> -M vicmd <span style="color: black;">"j"</span> down-line-or-beginning-search<h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">3、</span>Python包安装与配置</h1>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">1. 安装环境配置</h1><span style="color: black;"># 配置pypi源</span>
pip <span style="color: black;">install</span> pip -U
pip config <span style="color: black;">set</span>global.index-<span style="color: black;">url</span> https://pypi.tuna.tsinghua.edu.cn/simple
<span style="color: black;"># 依赖项</span>
pip <span style="color: black;">install</span> wheel
pip <span style="color: black;">install</span> setuptools <span style="color: black;">--upgrade</span>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">2 Python包安装</h1><span style="color: black;"><span style="color: black;">安装</span><span style="color: black;"><span style="color: black;">numpy</span></span><span style="color: black;">和</span><span style="color: black;"><span style="color: black;">scipy</span></span></span><span style="color: black;"># 添加第三方仓库</span>
<span style="color: black;">curl</span> <span style="color: black;">-LO https://its-pointless.github.io/setup-pointless-repo.sh</span>
<span style="color: black;">bash</span> <span style="color: black;">setup-pointless-repo.sh</span>
<span style="color: black;">
# 从仓库安装numpy scipy</span>
<span style="color: black;">p<span style="color: black;">公斤</span></span> <span style="color: black;">install -y numpy scipy</span><span style="color: black;"><span style="color: black;">安装</span><span style="color: black;"><span style="color: black;">lxml</span></span></span><span style="color: black;"># 安装lxml的依赖项</span>
<span style="color: black;">p<span style="color: black;">公斤</span></span> <span style="color: black;">install -y libxml2 libxslt</span>
<span style="color: black;">
# 安装lxml</span>
<span style="color: black;">pip</span> <span style="color: black;">install lxml</span><span style="color: black;"><span style="color: black;">安装</span><span style="color: black;"><span style="color: black;">pillow</span></span></span><span style="color: black;"># 安装pillow的依赖项</span>
<span style="color: black;">p<span style="color: black;">公斤</span></span> <span style="color: black;">install -y libjpeg-turbo libtiff </span>
<span style="color: black;">p<span style="color: black;">公斤</span></span> <span style="color: black;">install -y littlecms tk libwebp libsodium</span>
<span style="color: black;">
# 安装pillow</span>
<span style="color: black;">pip</span> <span style="color: black;">install pillow</span><span style="color: black;"><span style="color: black;">安装</span><span style="color: black;"><span style="color: black;">matplotlib</span></span></span><span style="color: black;"># 安装matplotlib的依赖项</span>
<span style="color: black;">p<span style="color: black;">公斤</span></span> <span style="color: black;">install -y freetype libpng</span>
<span style="color: black;">pip</span> <span style="color: black;">install kiwisolver cycler </span>
<span style="color: black;">pip</span> <span style="color: black;">install pyparsing python-dateutil</span>
<span style="color: black;"># 安装matplotlib</span>
<span style="color: black;">pip</span> <span style="color: black;">install matplotlib</span><span style="color: black;"><span style="color: black;">安装</span><span style="color: black;"><span style="color: black;">pandas</span></span></span><span style="color: black;"># 安装pandas的依赖项</span>
pip <span style="color: black;">install</span> -y pytz cython
<span style="color: black;"># 安装pandas</span>
<span style="color: black;">export</span> CFLAGS=<span style="color: black;">"-Wno-deprecated-declarations -Wno-unreachable-code"</span>
pip <span style="color: black;">install</span> pandas<span style="color: black;"><span style="color: black;">安装</span><span style="color: black;"><span style="color: black;">jupyter</span></span></span><span style="color: black;"># 安装jupyter依赖项</span>
<span style="color: black;">p<span style="color: black;">公斤</span></span> <span style="color: black;">install -y libzmq libcrypt p<span style="color: black;">公斤</span>-config</span>
<span style="color: black;">
# 安装jupyter </span>
<span style="color: black;">pip</span> <span style="color: black;">install jupyter</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">待安装完成,输入</span><span style="color: black;"><span style="color: black;">jupyter notebook</span></span><span style="color: black;"><span style="color: black;">起步</span>,将<span style="color: black;">位置</span>复制到浏览器中<span style="color: black;">就可</span>打开Jupyter。</span></span></p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/ae6110ad5e9c45eb990f89f104f4e69a~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723894245&x-signature=j%2FlVcrknHHkQx%2F%2FXMrm4nZ8aXJs%3D" style="width: 50%; margin-bottom: 20px;"></div>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">四、IPython和NeoVim配置</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">针对</span><span style="color: black;">期盼</span>在终端下进行<span style="color: black;">运用</span>的<span style="color: black;">朋友</span>,<span style="color: black;">举荐</span>IPython+NeoVim组合。</span></span></p>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">1. IPython配置</h1><span style="color: black;"><span style="color: black;">安装</span><span style="color: black;"><span style="color: black;">IPython</span></span></span><span style="color: black;"># 安装yapf</span>
<span style="color: black;">pip</span> <span style="color: black;">install yapf</span>
<span style="color: black;">
# 安装Pygments</span>
<span style="color: black;">pip</span> <span style="color: black;">install pygments</span>
<span style="color: black;">
# 安装ipython</span>
<span style="color: black;">pip</span> <span style="color: black;">install ipython</span><span style="color: black;"><span style="color: black;">创建配置文件</span></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">运用</span></span><span style="color: black;"><span style="color: black;">ipython profile create</span></span><span style="color: black;">命令在</span><span style="color: black;"><span style="color: black;"><span style="color: black;">~/.ipython/profile_default/</span></span></span><span style="color: black;">目录下的创建</span><span style="color: black;"><span style="color: black;">ipython_config.py</span></span><span style="color: black;">配置文件。</span></span></p><span style="color: black;"><span style="color: black;">修改配置文件</span></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">运用</span>neovim、nano等终端编辑器修改</span><span style="color: black;"><span style="color: black;"><span style="color: black;">~/.ipython/profile_default/</span></span></span><span style="color: black;">目录下的</span><span style="color: black;"><span style="color: black;">ipython_config.py</span></span><span style="color: black;">文件,添加如下配置:</span></span></p><span style="color: black;"># 配置终端颜色</span>
<span style="color: black;">c.InteractiveShell.colors</span> = <span style="color: black;">Linux</span>
<span style="color: black;">c.TerminalInteractiveShell.autoformatter</span> = <span style="color: black;">yapf</span>
<span style="color: black;"># 配置高亮<span style="color: black;">方法</span>,可<span style="color: black;">经过</span>pygmentize -L styles浏览所有可选配置</span>
<span style="color: black;">c.TerminalInteractiveShell.highlight_style</span> = <span style="color: black;">monokai</span>
<span style="color: black;"># 配置魔术命令%editor<span style="color: black;">运用</span>的编辑器</span>
<span style="color: black;">c.TerminalInteractiveShell.editor</span> = <span style="color: black;">nvim</span>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">2. NeoVim配置</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">在配置NeoVim前,<span style="color: black;">必须</span>安装pynvim插件,以扩展NeoVim对Python的支持。</span></span></p><span style="color: black;">pip</span> install pynvim<span style="color: black;"><span style="color: black;">创建init.vim文件进行基本配置</span></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">在命令行下,<span style="color: black;">经过</span></span><span style="color: black;"><span style="color: black;">nvim</span></span><span style="color: black;">命令进入NeoVim编辑器,输入</span><span style="color: black;"><span style="color: black;">:e $MYVIMRC</span></span><span style="color: black;">编辑NeoVim配置文件,<span style="color: black;">运用</span></span><span style="color: black;"><span style="color: black;">:w</span></span><span style="color: black;">进行<span style="color: black;">保留</span>,基本设置如下:</span></span></p><span style="color: black;">"</span> <span style="color: black;"><span style="color: black;">通常</span>设置</span>
<span style="color: black;">set</span> <span style="color: black;">nocompatible "关闭与vi的兼容模式</span>
<span style="color: black;">set</span> <span style="color: black;">number "<span style="color: black;">表示</span>行号</span>
<span style="color: black;">set</span> <span style="color: black;">nowrap "不自动折行</span>
<span style="color: black;">set</span> <span style="color: black;">showmatch "<span style="color: black;">表示</span>匹配的括号</span>
<span style="color: black;">set</span> <span style="color: black;">scrolloff=3 "距离顶部和底部3行"</span>
<span style="color: black;">set</span> <span style="color: black;">encoding=utf-8 "编码</span>
<span style="color: black;">set</span> <span style="color: black;">fenc=utf-8 "编码</span>
<span style="color: black;">set</span> <span style="color: black;">fileencodings=utf-8</span>
<span style="color: black;">set</span> <span style="color: black;">hlsearch "搜索高亮</span>
<span style="color: black;">syntax</span> <span style="color: black;">on "语法高亮</span>
<span style="color: black;">set</span> <span style="color: black;">tabstop=4 "tab宽度</span>
<span style="color: black;">set</span> <span style="color: black;">shiftwidth=4 </span>
<span style="color: black;">set</span> <span style="color: black;">smarttab</span>
<span style="color: black;">set</span> <span style="color: black;">backspace=indent,eol,start</span>
<span style="color: black;">set</span> <span style="color: black;">expandtab "tab替换为空格键</span>
<span style="color: black;">set</span> <span style="color: black;">fileformat=unix "<span style="color: black;">保留</span>文件格式</span>
<span style="color: black;">set</span> <span style="color: black;">splitbelow</span>
<span style="color: black;">set</span> <span style="color: black;">cmdheight=2</span>
<span style="color: black;">set</span> <span style="color: black;">completeopt=longest,menu</span>
<span style="color: black;">set</span> <span style="color: black;">splitright</span>
<span style="color: black;">set</span> <span style="color: black;">foldmethod=indent</span>
<span style="color: black;">set</span> <span style="color: black;">foldlevel=99</span>
<span style="color: black;">"</span> <span style="color: black;">设置空格为leader键</span>
<span style="color: black;">let</span> <span style="color: black;">mapleader=" "</span><span style="color: black;"><span style="color: black;"><span style="color: black;">运用</span></span><span style="color: black;"><span style="color: black;">vim-plug</span></span><span style="color: black;">安装NeoVim插件</span></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">vim-plug</span></span><span style="color: black;">是一款Vim插件管理工具,支持异步并行,<span style="color: black;">能够</span>快速安装、更新或卸载插件。<span style="color: black;">能够</span><span style="color: black;">经过</span>如下命令进行安装,或手动下载</span><span style="color: black;"><span style="color: black;">plug.vim</span></span><span style="color: black;">文件,复制到在</span><span style="color: black;"><span style="color: black;">~/.config/nvim/autoload</span></span><span style="color: black;">文件夹中。</span></span></p>curl -fLo ~<span style="color: black;">/.config/nvim</span><span style="color: black;">/autoload/plug</span>.vim --create-dirs \<span style="color: black;">https:</span>/<span style="color: black;">/raw.githubusercontent.com/junegunn</span><span style="color: black;">/vim-plug/master</span><span style="color: black;">/plug.vim</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">运用</span></span><span style="color: black;"><span style="color: black;">vim-plug</span></span><span style="color: black;">时,<span style="color: black;">必须</span>在init.vim中添加下列代码块。</span></span></p>" vim-plug插件管理
<span style="color: black;">call</span> plug<span style="color: black;">#begin(~/.config/nvim/plugged)</span>
Plug <span style="color: black;">junegunn/vim-plug</span>
<span style="color: black;">call</span> plug<span style="color: black;">#end()</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">保留</span>后,在普通模式下输入</span><span style="color: black;"><span style="color: black;">:so %</span></span><span style="color: black;">使配置文件生效,再<span style="color: black;">经过</span></span><span style="color: black;"><span style="color: black;">:PlugInstall</span></span><span style="color: black;">进行安装。</span></span></p><span style="color: black;"><span style="color: black;">常用插件及设置</span></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">下面列举了一下常用插件和基本设置:</span></span></p><span style="color: black;">call</span> <span style="color: black;">plug#begin(~/.config/nvim/plugged)</span>
<span style="color: black;">Plug</span> <span style="color: black;">junegunn/vim-plug</span>
<span style="color: black;">"</span> <span style="color: black;">git支持</span>
<span style="color: black;">Plug</span> <span style="color: black;">tpope/vim-fugitive</span>
<span style="color: black;">"</span> <span style="color: black;">Python自动缩进插件</span>
<span style="color: black;">Plug</span> <span style="color: black;">vim-scripts/indentpython.vim</span>
<span style="color: black;">"</span> <span style="color: black;">项目管理工具</span>
<span style="color: black;">Plug</span> <span style="color: black;">mhinz/vim-startify</span>
<span style="color: black;">"</span> <span style="color: black;">快速对齐插件</span>
<span style="color: black;">Plug</span> <span style="color: black;">junegunn/vim-easy-align</span>
<span style="color: black;">"</span> <span style="color: black;">当前光标下的单词<span style="color: black;">增多</span>下划线</span>
<span style="color: black;">Plug</span> <span style="color: black;">itchyny/vim-cursorword</span>
<span style="color: black;">"</span> <span style="color: black;">快速<span style="color: black;">选取</span>插件</span>
<span style="color: black;">Plug</span> <span style="color: black;">tpope/vim-surround</span>
<span style="color: black;">"</span> <span style="color: black;">自定义代码片断</span>
<span style="color: black;">Plug</span> <span style="color: black;">honza/vim-snippets</span>
<span style="color: black;">"</span> <span style="color: black;">语法高亮支持</span>
<span style="color: black;">Plug</span> <span style="color: black;">sheerun/vim-polyglot</span>
<span style="color: black;">"</span> <span style="color: black;">主题、状态栏设置</span>
<span style="color: black;">Plug</span> <span style="color: black;">haishanh/night-owl.vim</span>
<span style="color: black;">Plug</span> <span style="color: black;">vim-airline/vim-airline</span>
<span style="color: black;">Plug</span> <span style="color: black;">vim-airline/vim-airline-themes</span>
<span style="color: black;">Plug</span> <span style="color: black;">ryanoasis/vim-devicons</span>
<span style="color: black;">"</span> <span style="color: black;">coc扩展</span>
<span style="color: black;">Plug</span> <span style="color: black;">neoclide/coc.nvim, {branch: release}</span>
<span style="color: black;">"</span> <span style="color: black;">fzf模糊<span style="color: black;">查询</span></span>
<span style="color: black;">Plug</span> <span style="color: black;">junegunn/fzf, { dir: ~/.fzf, do: ./install --all }</span>
<span style="color: black;">Plug</span> <span style="color: black;">junegunn/fzf.vim</span>
<span style="color: black;">"</span> <span style="color: black;">whichkey快捷菜单</span>
<span style="color: black;">Plug</span> <span style="color: black;">liuchengxu/vim-which-key</span>
<span style="color: black;">"</span> <span style="color: black;">浮动窗口支持</span>
<span style="color: black;">Plug</span> <span style="color: black;">voldikss/vim-floaterm</span>
<span style="color: black;">"</span> <span style="color: black;">ranger文件管理器支持</span>
<span style="color: black;">Plug</span> <span style="color: black;">kevinhwang91/rnvimr</span>
<span style="color: black;">call</span> <span style="color: black;">plug#end()</span>
<span style="color: black;">"</span> <span style="color: black;">启用标签栏</span>
<span style="color: black;">let</span> <span style="color: black;">g:airline#extensions#tabline#enabled = 1</span>
<span style="color: black;">"</span> <span style="color: black;">支持图标字体</span>
<span style="color: black;">let</span> <span style="color: black;">g:airline_powerline_fonts = 1</span>
<span style="color: black;">"</span> <span style="color: black;">设置状态栏主题</span>
<span style="color: black;">let</span> <span style="color: black;">g:airline_theme=night_owl</span>
<span style="color: black;">"</span> <span style="color: black;">设置主题</span>
<span style="color: black;">set</span> <span style="color: black;">termguicolors</span>
<span style="color: black;">let</span> <span style="color: black;">&t_8f = "\<Esc>[38;2;%lu;%lu;%lum"</span>
<span style="color: black;">let</span> <span style="color: black;">&t_8b = "\<Esc>[48;2;%lu;%lu;%lum"</span>
<span style="color: black;">syntax</span> <span style="color: black;">enable</span>
<span style="color: black;">colorscheme</span> <span style="color: black;">night-owl</span>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/04e63f06532a4548973a96853cdd42c8~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723894245&x-signature=IBvJHGbKhNQJpaOf9dtFknsyeJQ%3D" style="width: 50%; margin-bottom: 20px;"></div><span style="color: black;"><span style="color: black;">安装、配置coc.nvim扩展</span></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">coc.nvim是一款支持扩展的插件,类似于油猴,<span style="color: black;">能够</span><span style="color: black;">经过</span>安装扩展,以实现像Vscode<span style="color: black;">同样</span><span style="color: black;">运用</span>NeoVim,下面列举了Python<span style="color: black;">关联</span>的coc扩展和配置:</span></span></p><span style="color: black;">" coc扩展
let g:coc_global_extensions = [
\coc-json,
\coc-pyright,
\coc-snippets,
\coc-xml,
\coc-explorer,
\coc-prettier,
\coc-highlight]
"</span> <span style="color: black;">运用</span>tab键进行补全<span style="color: black;">选取</span>
inoremap <silent><expr> <TAB>
\ pumvisible() ? <span style="color: black;">"\<C-n>"</span> :
\ <SID>check_back_space() ? <span style="color: black;">"\<TAB>"</span> :
\ coc<span style="color: black;">#refresh()</span>
inoremap <expr><S-TAB> pumvisible() ? <span style="color: black;">"\<C-p>"</span> : <span style="color: black;">"\<C-h>"</span>
<span style="color: black;">function</span>! s:check_back_space() abort
<span style="color: black;">let</span> col = col(<span style="color: black;">.</span>) - 1
<span style="color: black;">return</span> !col || getline(<span style="color: black;">.</span>) =~<span style="color: black;"># \s</span>
endfunction
<span style="color: black;">" <span style="color: black;">运用</span>回车进行补全<span style="color: black;">选取</span>
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "</span>\<C-g>u\<CR>\<c-r>=coc<span style="color: black;">#on_enter()\<CR>"</span>
<span style="color: black;">" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync(highlight)
"</span>Add `:Format`<span style="color: black;">command</span> to format current buffer.
<span style="color: black;">command</span>! -nargs=0 Format :call CocAction(<span style="color: black;">format</span>)
<span style="color: black;">" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction(fold, <f-args>)
"</span> Add `:OR` <span style="color: black;">command</span> <span style="color: black;">for</span> organize imports of the current buffer.
<span style="color: black;">command</span>! -nargs=0 OR :call CocAction(<span style="color: black;">runCommand</span>, <span style="color: black;">editor.action.organizeImport</span>)
<span style="color: black;">" 添加状态栏<span style="color: black;">表示</span>支持
set statusline^=%{coc#status()}%{get(b:,coc_current_function,)}
"</span>启用Prettier进行文件自动格式化<span style="color: black;">command</span>! -nargs=0 Prettier :CocCommand prettier.formatFile
<span style="color: black;">let</span> g:prettier<span style="color: black;">#autoformat = 1</span>
<span style="color: black;">" 设置Coc Search
nnoremap <leader>? :CocSearch <C-R>=expand("</span><cword><span style="color: black;">")<CR><CR></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">另外</span>,coc扩展<span style="color: black;">能够</span><span style="color: black;">经过</span>在</span><span style="color: black;"><span style="color: black;">~/.config/nvim/</span></span><span style="color: black;">文件夹中创建</span><span style="color: black;"><span style="color: black;">coc-settings.json</span></span><span style="color: black;">文件来进行配置:</span></span></p>{
<span style="color: black;">"python.defaultInterpreterPath"</span>: <span style="color: black;">"/data/data/com.termux/files/usr/bin/python"</span>,
<span style="color: black;">"python.pythonPath"</span>: <span style="color: black;">"/data/data/com.termux/files/usr/bin/python"</span>,
<span style="color: black;">"python.linting.pylintEnable"</span>:<span style="color: black;">true</span>,
<span style="color: black;">"python.formatting.provider"</span>: <span style="color: black;">"yapf"</span>,
<span style="color: black;">"python.formatting.yapfArgs"</span>: [
<span style="color: black;">"--style"</span>,
<span style="color: black;">"{SPACES_AROUND_POWER_OPERATOR: True, SPACES_BEFORE_COMMENT: 1}"</span>
],
<span style="color: black;">"explorer.width"</span>: <span style="color: black;">38</span>,
<span style="color: black;">"explorer.quitOnOpen"</span>: <span style="color: black;">true</span>,
<span style="color: black;">"explorer.sources"</span>: [
{
<span style="color: black;">"name"</span>: <span style="color: black;">"buffer"</span>,
<span style="color: black;">"expand"</span>: <span style="color: black;">false</span>
},
{
<span style="color: black;">"name"</span>: <span style="color: black;">"file"</span>,
<span style="color: black;">"expand"</span>: <span style="color: black;">true</span>
}
],
<span style="color: black;">"explorer.file.column.indent.indentLine"</span>: <span style="color: black;">true</span>,
<span style="color: black;">"explorer.file.showHiddenFiles"</span>: <span style="color: black;">true</span>,
<span style="color: black;">"explorer.icon.enableNerdfont"</span>: <span style="color: black;">true</span>,
<span style="color: black;">"explorer.keyMappingMode"</span>: <span style="color: black;">"none"</span>,
<span style="color: black;">"explorer.buffer.showHiddenBuffers"</span>: <span style="color: black;">false</span>,
<span style="color: black;">"explorer.keyMappings.global"</span>: {
<span style="color: black;">"o"</span>: [<span style="color: black;">"wait"</span>, <span style="color: black;">"expanded?"</span>, <span style="color: black;">"collapse"</span>, <span style="color: black;">"expand"</span>],
<span style="color: black;">"<cr>"</span>: [<span style="color: black;">"wait"</span>, <span style="color: black;">"expandable?"</span>, <span style="color: black;">"cd"</span>, <span style="color: black;">"open"</span>],
<span style="color: black;">"?"</span>: <span style="color: black;">"help"</span>,
<span style="color: black;">"q"</span>: <span style="color: black;">"quit"</span>
},
<span style="color: black;">"coc.preferences.formatOnSaveFiletypes"</span>: [<span style="color: black;">"*"</span>],
<span style="color: black;">"prettier.printWidth"</span>: <span style="color: black;">100</span>,
<span style="color: black;">"prettier.eslintIntegration"</span>: <span style="color: black;">true</span>,
<span style="color: black;">"prettier.disableLanguages"</span>: [],
<span style="color: black;">"prettier.formatterPriority"</span>: <span style="color: black;">1</span>,
<span style="color: black;">"prettier.useTabs"</span>: <span style="color: black;">true</span>,
<span style="color: black;">"prettier.trailingComma"</span>: <span style="color: black;">"all"</span>,
<span style="color: black;">"prettier.singleQuote"</span>: <span style="color: black;">false</span>,
<span style="color: black;">"prettier.tabWidth"</span>: <span style="color: black;">4</span>
}<span style="color: black;"><span style="color: black;">配置vim-which-key</span></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">vim-which-key是一款快捷键映射插件,<span style="color: black;">能够</span><span style="color: black;">经过</span>简单的设置进行快捷键自定义功能的实现。下面列举了vim-which-key的简单设置:</span></span></p><span style="color: black;">" 将空格设置为whichkeyleader键
nnoremap <silent> <leader> :WhichKey <Space><CR>
"</span>whichkey基本配置<span style="color: black;">let</span> g:which_key_timeout = 100
<span style="color: black;">let</span> g:which_key_display_names = {<span style="color: black;"><CR></span>: <span style="color: black;">↵</span>, <span style="color: black;"><TAB></span>: <span style="color: black;">⇆</span>}
<span style="color: black;">let</span> g:which_key_map = {}
<span style="color: black;">let</span> g:which_key_sep = <span style="color: black;">→</span>
<span style="color: black;">let</span>g:which_key_use_floating_win = 0<span style="color: black;">let</span> g:which_key_max_size = 0
<span style="color: black;">" 呼出whichkey时<span style="color: black;">隐匿</span>状态栏
autocmd! FileType which_key
autocmd FileType which_key set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set laststatus=2 noshowmode ruler
"</span> 自定义whichkey
<span style="color: black;">let</span> g:which_key_map[<span style="color: black;">?</span>] = <span style="color: black;">search word</span>
<span style="color: black;">let</span>g:which_key_map[<span style="color: black;">/</span>] = [ <span style="color: black;">:call Comment()</span> , <span style="color: black;">comment</span> ]
<span style="color: black;">let</span> g:which_key_map[<span style="color: black;">.</span>] = [ <span style="color: black;">:e $MYVIMRC</span> , <span style="color: black;">open init</span> ]
<span style="color: black;">let</span> g:which_key_map[<span style="color: black;">;</span>] = [ <span style="color: black;">:Commands</span> , <span style="color: black;">commands</span> ]
<span style="color: black;">let</span> g:which_key_map[<span style="color: black;">e</span>] = [<span style="color: black;">:CocCommand explorer --toggle --sources=file+</span> , <span style="color: black;">explorer</span> ]
<span style="color: black;">let</span> g:which_key_map[<span style="color: black;">n</span>] = [ <span style="color: black;">:let @/ = ""</span> , <span style="color: black;">no highlight</span> ]
<span style="color: black;">let</span> g:which_key_map[<span style="color: black;">q</span>] = [ <span style="color: black;"><Plug>(coc-fix-current)</span> , <span style="color: black;">quickfix</span> ]
<span style="color: black;">let</span> g:which_key_map[<span style="color: black;">u</span>] = [ <span style="color: black;">:UndotreeToggle</span> , <span style="color: black;">undo tree</span>]
<span style="color: black;">let</span> g:which_key_map[<span style="color: black;">t</span>] = [<span style="color: black;">:FloatermNew --wintype=normal --height=6</span> , <span style="color: black;">terminal</span>]
<span style="color: black;">let</span>g:which_key_map[<span style="color: black;">r</span>] = [ <span style="color: black;">:FloatermNew ranger</span> , <span style="color: black;">ranger</span>]
<span style="color: black;">let</span> g:which_key_map[<span style="color: black;">f</span>] = [<span style="color: black;">:FloatermNew fzf</span> , <span style="color: black;">fzf</span>]
<span style="color: black;">let</span> g:which_key_map[<span style="color: black;">g</span>] = [<span style="color: black;">:FloatermNew lazygit</span> , <span style="color: black;">git</span>]
<span style="color: black;">let</span>g:which_key_map[<span style="color: black;">p</span>] = [<span style="color: black;">:FloatermNew python</span> , <span style="color: black;">python</span>]
call which_key<span style="color: black;">#register(<Space>, "g:which_key_map")</span>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/58996f5ff4954ffca108cc30c15b8daa~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723894245&x-signature=xUafdiuQkJzXOQwrr93aWpZdA7U%3D" style="width: 50%; margin-bottom: 20px;"></div>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p26-sign.toutiaoimg.com/pgc-image/b8e2a138118e4dbfa82f2ae491ef1db2~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723894245&x-signature=ApXRStjLaTI4jZh5lJTL3w69fPM%3D" style="width: 50%; margin-bottom: 20px;"></div>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p26-sign.toutiaoimg.com/pgc-image/44380af28a3b4cf0a0d3c59a4e3a09b2~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723894245&x-signature=XileDwCc9SjHADfKa%2FoZMcoKQeI%3D" style="width: 50%; margin-bottom: 20px;"></div>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/8e483d0739334c959ae8d799669e58aa~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723894245&x-signature=CW1Nc3XJMCsHxaNOqurxh%2FnnrMA%3D" style="width: 50%; margin-bottom: 20px;"></div><span style="color: black;"><span style="color: black;">在NeoVim中运行Python脚本</span></span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">能够</span><span style="color: black;">经过</span>在NeoVim中添加自定义功能,从而在编写时运行当前Python脚本。</span></span></p><span style="color: black;">"在普通模式下,按r来运行Python脚本</span>
<span style="color: black;">noremap</span> <span style="color: black;">r :call RunPython()<CR> </span>
<span style="color: black;">func!</span> <span style="color: black;">RunPython()</span>
<span style="color: black;">exec</span> <span style="color: black;">"w"</span>
<span style="color: black;">if</span> <span style="color: black;">&filetype == python</span>
<span style="color: black;">exec</span> <span style="color: black;">"!time python %"</span>
<span style="color: black;">endif</span>
<span style="color: black;">endfunc</span>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/ffeaf9eebc3c40979040bfd8fe370b69~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723894245&x-signature=goet%2FYtD1wwcgpFXnq2eE5%2FKrGk%3D" style="width: 50%; margin-bottom: 20px;"></div>
<h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">5、</span>结语</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">本文<span style="color: black;">重点</span>分享了一下在Android平板上配置Python学习环境的经验,<span style="color: black;">关联</span>配置文件请参见以下链接:</span></span><span style="color: black;"><span style="color: black;">https://gitee.com/knightz1224/termux_config</span></span><span style="color: black;"><span style="color: black;">,谢谢<span style="color: black;">大众</span>支持!</span></span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">作者:Python中文社区</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">原文链接:</p>https://mp.weixin.qq.com/s/v0_NkTOxmvUuaVvt5EYBVA
你的见解真是独到,让我受益匪浅。 交流如星光璀璨,点亮思想夜空。 你字句如珍珠,我珍藏这份情。 你的见解真是独到,让我受益匪浅。
页:
[1]