with open("example.txt", "r") as f: text_wrapper = io.TextIOWrapper(f, encoding="utf-8") lines = text_wrapper.readlines()
with open("output.txt", "w") as f: text_wrapper = io.TextIOWrapper(f, encoding="utf-8") text_wrapper.write("Hello, world!")In this example, we create a new file "output.txt" in write mode and wrap the file object in a TextIOWrapper instance. We then write the string "Hello, world!" to the wrapper using the write() method. The TextIOWrapper class is part of the standard library in Python, specifically in the io module.