import urllib.request
data=urllib.request.urlopen("file:///D:/Learnign/pro/Code%20Editor/d.txt")
print(data)
Output:
<addinfourl at 1642793087856 whose fp = <_io.BufferedReader name='D:\\Learnign\\pro\\Code Editor\\d.txt'>>
How to solve this problem? How to print text file data?
urllib.request.urlopenis designed so it could be used as context manager (seewithkeyword) so I would use something likeNote that it will probably return bytes, so you might need to decode it providing encoding used with given file, for example if it was UTF-8-encoded then print line might look as follows
Consult
codecsdocs for list of supporting encodings.