Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def read_tests(mode):
- with open("Myfile1.txt", mode="r", encoding="utf-8") as Fileobj:
- if mode == "read":
- data = Fileobj.read()
- elif mode == "readline":
- data = Fileobj.readline()
- else:
- data = Fileobj.readlines()
- print("{0}[{1}]: \n{2}".format(mode.upper(), len(data), data))
- def main():
- read_modes = "read readline readlines".split()
- sep = "-" * 20
- for mode in read_modes:
- print(sep)
- read_tests(mode)
- print(sep)
- print("File Read Successfully")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement