Python: I/O Operations
In this article we show how we can to input/output operations using user input and file. Python supports standard keyboard input and screen output using input and print keywords, respectively. File I/O has more option depending if you want to write, read or append a file. Python also supports text and binary mode of writing,however both modes have a very minor difference based on how cr-lf ('\r\n') is handled. The following code sample demonstrate how interactive user input and output are handled in Python. After that we look at code sample to perform File I/O. Inline comments (starting with # ) clarify the purpose of specific lines of code. # Code for demonstration of Python Dictionary class DemoScreenIOClass: def ReadFromKeyboard(self): print("---------- ReadFromKeyboard") # Read a value from keyboard self.__value = input('Enter any value:') # Validation can be added using a try-except block self.__numValue =...