echo '{"job": "developer", "name": "lmx", "sex": "male"}'|python -m json.tool
测试第三方模块是否导入:
python3 -c 'import scrapy'
参考:https://www.cnblogs.com/yangmingxianshen/p/11029532.html
安装pip:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py # 运行安装脚本
pip3 completion --bash >> ~/.profile && source ~/.profile
国内镜像:
临时使用:
pip3 install flask -i https://pypi.tuna.tsinghua.edu.cn/simple/
永久配置:
mkdir ~/.pip && echo -e "[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple/" > ~/.pip/pip.conf
离线安装:将安装包下载至本地,然后选择从本地安装
#单个离线
pip3 download requests -d ./pkg
pip3 install requests --no-index --find-links=./pkg
#多个离线
pip3 freeze > requirements.txt
pip3 download -r requirements.txt -d ./pkg
pip3 install -r requirements.txt --no-index --find-links=./pkg
#--find-links=./pkg 等价于 -f ./pkg
pip3 install requests --no-index -f ./pkg
参考:https://blog.csdn.net/qq_26877377/article/details/80717755
安装vundle:
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
# 在VIM中安装插件:BundleInstall
VIM配置:~/.vimrc
"""""""""
"一键执行
"""""""""
map :call CompileRunGcc()
func! CompileRunGcc()
exec " w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!time java %<"
elseif &filetype == 'sh'
:!time bash %
elseif &filetype == 'python'
exec "!time python %"
elseif &filetype == 'html'
exec "!firefox % &"
elseif &filetype == 'go'
exec "!go build %<"
exec "!time go run %"
elseif &filetype == 'mkd'
exec "!~/.vim/markdown.pl % > %.html &"
exec "!firefox %.html &"
endif
endfunc
"""""""""""""""
"添加vundle支持
"""""""""""""""
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
"""""""""
"添加插件
"""""""""
if &compatible
set nocompatible
end
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Let Vundle manage Vundle
Bundle 'gmarik/vundle'
" python自动补全
Bundle 'davidhalter/jedi-vim'
Bundle "klen/python-mode"
" 括号匹配高亮
Bundle 'kien/rainbow_parentheses.vim'
" 可视化缩进
Bundle 'nathanaelkane/vim-indent-guides'
if filereadable(expand("~/.vimrc.bundles.local"))
source ~/.vimrc.bundles.local
endif
filetype on
"""""""""""""
"添加插件配置
"""""""""""""
问题:[Pymode]: error: Pymode requires vim compiled with +python. Most of features will be disabled.
参考:
https://blog.csdn.net/Vairsly/article/details/76385206
https://blog.csdn.net/github_35817521/article/details/53467610
https://blog.csdn.net/yxiaom/article/details/103468954
安装工具:
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
配置工具:
export PATH="/root/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
source ~/.bashrc
pyenv --version
下载镜像:
wget http://mirrors.sohu.com/python/2.7.15/Python-2.7.15.tar.xz -P ~/.pyenv/cache/
安装python:
# 提前安装python依赖
pyenv install 2.7.15
pyenv常用命令:
pyenv virtualenv命令:
import yagmail
username = '[email protected]' # 邮箱账号
passwd = '******' # 授权码,不是邮箱密码
host = 'smtp.qq.com'
mail = yagmail.SMTP(user=username,
password=passwd,
host=host,
# smtp_ssl=True
) # 如果用的是qq邮箱或者你们公司的邮箱使用是安全协议的话,必须写上 smtp_ssl=True
mail.send(
to=['[email protected]', '[email protected]'], # 多个人列表,一个人字符串形式
cc='[email protected]', # 抄送
subject='学习发送邮件', # 邮件标题
contents='你好,你今天开心吗?', # 邮件正文
attachments=[r'C:\Users\only\python\Arithmetic\bubble_sort.py',
r'C:\Users\only\python\Arithmetic\insertion_sort.py']
)
print('发送成功')