不需要换行符时 使用file.read().splitlines()
with open("file.txt", "r") as file: lines = file.readlines() print(lines) # ['Line 1\n', 'Line 2\n', 'Line 3\n']
with open("file.txt", "r") as file: content = file.read().splitlines() print(content) # ['Line 1', 'Line 2', 'Line 3']