我想在ubuntu上使用python檢索文件的行數。檢索Python的行數
我試過如下:
os.system("wc -l fileName")
但它返回像
numberOfLines fileName
0
當我試圖檢索結果: L =使用os.system( 「WC -l文件名」)
我l = 0
我也嘗試過爲了保留第一個元素而分開結果,但是這提高了AttributeError: 'int' object has no attribute 'split'
如何獲得我正在查找的行數?
可能重複[如何獲得線在Python便宜算什麼?](http://stackoverflow.com/questions/845058/how-to- get-line-count-cheaply-in-python) – pseudocubic
http://docs.python.org/2/library/os.html#os.system – dm03514