1: commands 被 subprocess 所取代:举例
Python2中使用getoutput:
>>> import commands >>> print(commands.getoutput('ls /usr/')) bin etc games include lib lib64 libexec local sbin share src tmp
Python3中使用getoutput:
>>> 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中:举例:
Python2中使用urlopen:
import urllib url.urlopen("www.xxx.com")
Python3中使用urlopen:
import urllib.request url.request.urlopen("www.xxx.com")