Python:从数组创建子串数组

时间:2017-12-09 01:03:13

标签: python arrays

我从txt文件的行中抓取了一个数组。问题是我只需要这些行的结尾。我仍然是Python的新手,所以我不确定如何将这些概念放在一起。以下是我最好的尝试,第一部分可行但第二部分则分崩离析。

 with open("prices.txt") as f:
        readline = f.readlines()

 for seatCapacity in readline:
        seatCapacity = readline[10:]

1 个答案:

答案 0 :(得分:2)

我想,你想要这样。

with open("prices.txt") as f:
     for line in f: 
     seatCapacity = line[10:]

您可以参考此解决方案:How should I read a file line-by-line in Python?