1: commands 被 subprocess 所取代:舉例url
Python2中使用getoutput:spa
>>> import commands >>> print(commands.getoutput('ls /usr/')) bin etc games include lib lib64 libexec local sbin share src tmp
Python3中使用getoutput:code
>>> import subprocess >>> print(subprocess.getoutput('ls /usr/')) bin etc games include lib lib64 libexec local sbin share src tmp
2: Python2中的urllib被移植到Python3的urllib.request中:舉例:blog
Python2中使用urlopen: get
import urllib url.urlopen("www.xxx.com")
Python3中使用urlopen:class
import urllib.request url.request.urlopen("www.xxx.com")