
subprocess.run()函数的功能是运行命令并返回一个CompletedProcess` 实例。
返回的实例将具有 args、returncode、stdout 和 stderr 属性。默认情况下,stdout 和 stderr 不被捕获,这些属性将为 None。要捕获它们,请传递 stdout=PIPE 和/或 stderr=PIPE,或者传递 capture_output=True 以同时捕获两者。
如果 check 为 True 并且退出代码非零,则它会引发 CalledProcessError。CalledProcessError 对象将在 returncode 属性中包含退出代码,以及输出和 stderr 属性(如果捕获了这些流)。
如果给定了 timeout,并且进程花费的时间太长,则会引发 TimeoutExpired 异常。
有一个可选参数 "input",允许您将字节或字符串传递给子进程的 stdin。如果您使用此参数,则不能同时使用 Popen 构造函数的 "stdin" 参数,因为它将在内部使用。
默认情况下,所有通信都是以字节为单位的,因此任何 "input" 都应该是字节,stdout 和 stderr 都应该是字节。如果处于文本模式,任何 "input" 都应该是一个字符串,stdout 和 stderr 将根据区域设置编码或通过设置 "encoding" 进行解码的字符串。文本模式可以通过设置 text、encoding、errors 或 universal_newlines 中的任何一个来触发。
推薦hahow線上學習python: https://igrape.net/30afN


![Python: pandas.DataFrame()處理雙維度資料,dict跟2D list轉為DataFrame有何差別?如何用index及columns屬性客製化index跟欄位名稱?df.index = [“一”,”二”,”三”,”四”] ; df.columns = 使用.head(n) ; .tail(m) ;取首n列,尾m列; .at[index,欄位名稱] 取單一資料 ; .iat[index,欄位順序] 取單一資料 ; .loc[index,欄位名稱] 取資料 ; .iloc[index,欄位順序];df.iloc[ [0,1],[0,2]])取資料 ; df.iloc[ 0:3,0:2]切片 Python: pandas.DataFrame()處理雙維度資料,dict跟2D list轉為DataFrame有何差別?如何用index及columns屬性客製化index跟欄位名稱?df.index = [“一”,”二”,”三”,”四”] ; df.columns = 使用.head(n) ; .tail(m) ;取首n列,尾m列; .at[index,欄位名稱] 取單一資料 ; .iat[index,欄位順序] 取單一資料 ; .loc[index,欄位名稱] 取資料 ; .iloc[index,欄位順序];df.iloc[ [0,1],[0,2]])取資料 ; df.iloc[ 0:3,0:2]切片](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2022/11/20221111093547_79.png?quality=90&zoom=2&ssl=1&resize=350%2C233)







近期留言