6

我正在制作一个包含多项选择答案的测验的基本程序。我想从 .DAT 文件中访问数据。这是 .DAT 文件的基本布局。

Which sport uses the term LOVE ?
Tennis
Golf
Football
Swimming
A

如何分别访问每条线路?

4

1 回答 1

13
for line in open(filename, 'r'):
    item = line.rstrip() # strip off newline and any other trailing whitespace
    ...

奖金:网球!

于 2013-08-20T16:37:44.433 回答