[問題] file讀取問題
class random_pick:
def __init__(self,file_name):
self.r_content = open(file_name).readlines()
def random_pick(self,num):
w_content = random.sample(self.r_content,num)
def writeTofile(self):
pass
def mergeFile(self,*files):
self.data = []
for file_name in files:
self.data = open(file_name).readlines()
files = ['0.txt','t2.txt']
x.mergeFile(files)
在mergeFile這個function會出錯,
誤訊息是TypeError: coercing to Unicode: need string or buffer, list found
改了很多次還是不曉得為啥會錯= ="
這個function主要是拿來把很多檔案合成一個,方便處理
不過現在寫的有些問題,希望各位能幫忙看看@@"
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.223.231
→
07/21 00:42, , 1F
07/21 00:42, 1F
→
07/21 00:44, , 2F
07/21 00:44, 2F
→
07/21 00:48, , 3F
07/21 00:48, 3F
→
07/21 01:10, , 4F
07/21 01:10, 4F
→
07/21 01:12, , 5F
07/21 01:12, 5F
推
07/21 08:46, , 6F
07/21 08:46, 6F
→
07/21 08:46, , 7F
07/21 08:46, 7F
討論串 (同標題文章)
Python 近期熱門文章
PTT數位生活區 即時熱門文章