The problem of enurmate reading files in python

self.official_account = os.getcwd () + "/" + "official_account.rtf"
for index,content in enumerate (open (self.official_account,"r")):

        print(content,end="")

clipboard.png


i love you
ich liebe dich
heissen dank

clipboard.png

Mar.23,2021

is your rtf file with one word and one line.

In [6]: 
   ...: for i, l in enumerate(open('haha.txt')):
   ...:     print(l, end="")
   ...: 
hello world
miao
haha

there is no problem with my test


I don't think you need to subscript the list of requirements. You don't need to use enumerate, and just use the for loop. The former is less efficient than the latter.

>>> import timeit
>>> timeit.timeit('for i in xrange(100): a[i]', 'a = list(xrange(100))')
7.2920000553131104
>>> timeit.timeit('for i, o in enumerate(a): o', 'a = list(xrange(100))')
10.359999895095825
Menu