我的文件的Python閱讀文件錯誤:與陣列
Offices 10
MedicalOffice 15
PostOffice 30
Mall 200
如何讓我的蟒蛇只讀第二列。 像得到:
10
15
30
200
我已經試過可能的方法來使它只讀,10,15,30,等等。相反的名稱。我試過這個沒有名字,它工作正常。但我需要在文本文件中包含名稱。任何幫助?謝謝
def something(file1):
with file1 as f:
nums = [int(line) for line in f]
print("Read from File: ", nums)
textFileName = input("Enter the filename: ")
file1 = open(textFileName)
something(file1)
謝謝。
這是第二個_column_。第二個_row_是'MedicalOffice 15'。 – abarnert
@abarnert好抓住那裏。我的錯字。感謝您的支持! – Singh2013
是的,我認爲這只是一個錯字,但更好的解決它,而不是混淆未來的讀者... – abarnert