标签:utf-8 为什么 readline sys pycharm pip lines system pytho
# --*--encoding: utf-8--*-- import os import subprocess os_system = os.system(‘dir‘) print os_system #只获取了返回值,如果获取输出需如下: re = os.system(‘dir>C:\Users\Administrator\PycharmProjects\dir.txt‘) print re print open(‘C:\Users\Administrator\PycharmProjects\dir.txt‘,‘r‘).readlines() re1 = os.popen(‘dir‘) print re1.read() print ‘-‘ * 20 re2 = subprocess.Popen(‘dir‘, shell=True, stdout=subprocess.PIPE) print re2 print re2.stdout.read() re3 = subprocess.call((‘dir‘,‘C:/Users/Administrator/PycharmProjects/‘),shell=True) print re3
标签:utf-8 为什么 readline sys pycharm pip lines system pytho
原文地址:http://www.cnblogs.com/EWWE/p/7050930.html