2
我想檢索一些關於我的perforce客戶端使用python腳本的信息。我只希望獲取相關服務器的地址信息,cleint根等如下:如何從一個子進程命令獲取輸出作爲Python中的列表?
ping_string = subprocess.Popen(['p4', 'info','ls'], stdout=subprocess.PIPE).communicate()[0]
print ping_string
,所以我得到輸出:
User name: hello
Client name: My_machine
Client host: XYZ
Current directory: c:\
Peer address: 1.2...
Client address: 1.102....
Server address: abcd
Server root: D:\scc\data
但正如我想要檢索服務器地址,客戶端地址等所以,爲此,我希望輸出爲列表的形式。所以,請建議如何以列表類型的形式獲得輸出。