コードはpython 2.7とpython 3を同時に互換性があります
2364 ワード
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# python2 unicode,
from __future__ import unicode_literals
try:#python2
from UserDict import UserDict
# python3 import
from UserDict import DictMixin as MutableMapping
except ImportError:#python3
from collections import UserDict
from collections import MutableMapping
# ini
try:
import ConfigParser as configparser
except ImportError:
import configparser
#
print("ENDPOINT: {} ".format(ENDPOINT))
# : TypeError: cannot use a string pattern on a bytes-like object
s = s.decode('utf8')
説明:
python=3.6.8
test -f Python-${python}.tar.xz || wget -c https://www.python.org/ftp/python/${python}/Python-${python}.tar.xz
tar Jxf Python-${python}.tar.xz
cd Python-${python}
EXTRATESTOPTS=--list-tests
./configure --enable-optimizations --prefix=/usr/local
make -j8
sudo make install
CentOS 7のepelウェアハウス、インストール可能
yum install -y python36-devel python36-setuptools
easy_install-3.6 pip
ln -s /bin/python3.6 /bin/python3
pip3 install -U httpie requests mongo redis psutil pymysql stomp.py python3-memcached virtualenv paramiko sh pycurl ipython pyyaml httpie mysqlclient pymemcache cx_Oracle
APP=python36
VERSION=3.6.8
PREFIX=/usr/local
fpm -s dir -t rpm -n ${APP} -v ${VERSION} --epoch 0 --rpm-user=root \
-p ${APP}-${VERSION}.rpm \
$PREFIX/bin/2to3 $PREFIX/bin/idle3 $PREFIX/bin/pip3 $PREFIX/bin/pydoc3 \
$PREFIX/bin/python3 $PREFIX/bin/python3-config $PREFIX/bin/pyvenv \
$PREFIX/bin/*3.6 $PREFIX/include/python3.6m \
$PREFIX/lib/libpython3.6m.a $PREFIX/lib/python3.6 $PREFIX/lib/pkgconfig/python-3*.pc \
$PREFIX/lib/pkgconfig/python3*.pc $PREFIX/share/man/man1/python3.*
参照先:
http://python.jobbole.com/83987/