我有以下代碼:類型錯誤:預期的字符緩衝區對象
import os
import csv
listing = os.listdir('/directory/my/files/are/in')
os.chdir('/directory/my/files/are/in')
for file in listing[1:]:
r = csv.reader(open(file, 'rU'))
for row in r:
stuff = [str.split('\t', 1) for row in r]
print stuff
返回TypeError: expected a character buffer object
。我該如何解決?基本上,我想在目錄中打開所有文件(CSV),然後從每個細胞切出一定的垃圾(後一切,包括/噸)。
爲什麼你不想處理'listing [0]'? –