我如何編寫代碼將在輸出插入插入斷裂線,那裏有一個輸入?
代碼
data1=[]
with open("FileInput1.txt") as file:
for line in file:
data1.append([float(f) for f in line.strip().split()])
data2=[]
with open("FileInput2.csv") as File2:
for line in File2:
data2.append([f for f in line.strip().split()])
樣品輸入:
文件輸入#1
1223 32 (userID - int = 1223, work hours = 32) 2004 12.2 8955 80
一個。電流輸出
1223 32 2004 12.2 8955 80
FileInput2:
UserName 3423 23.6 Name 6743 45.9
一個。電流輸出
UserName 3423 23.6 Name 6743 45.9
提供一個示例fileDoc.txt?在[pastebin]上(http://pastebin.com/),我會在接下來的5分鐘內嘲弄一些東西。 – Killrawr 2013-03-12 23:43:27
請考慮使用內置的'csv'模塊。有很多相關的SO問題和答案。 – bernie 2013-03-12 23:44:50
@Killrawr我剛剛添加了兩個不同的文件,我將從 – Masriyah 2013-03-12 23:49:27