Back to Coding Snippet

Pip update all packages

1
pip install -U $(pip freeze | awk '{split($0, a, "=="); print a[1]}')

Tips-Python

nschloe/pipdated: Python module for checking for updates on PyPi.

虚拟环境 — Python最佳实践指南 virtualenv

Curl http… > reddit.json

More reddit.json

Pasted Graphic 1.tiff

Like pretty()

Pasted Graphic.tiff

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
for python 3
pip install bottle
For python 2
Sudo python -m easy_install bottle
Sudo python2.7 -m pip install scipy
//if the eviroment already has the python 2 and python 3, use this command to install the package
py -2.7
Upgrade python2 package
sudo python2.7 -m pip install --upgrade numpy
pip2 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip2 install -U
# Use Homebrew :)
brew install python3
# To update it:
brew update
brew upgrade python3

##读取json文件并转换为字典

1
2
3
4
5
# -*- coding:utf-8 -*-
import json
file_path = 'json文件相对路径或者据对路径'
with open(file_path) as f:
js = json.load(f) # js是转换后的字典