So far, we’ve mainly been working with data structures that reside in the interpreter itself. What little interaction our programs have had with the outside world has been through input and print. In this chapter, we go one step further and let our programs catch a glimpse of a larger world: the world of files and streams. The functions and objects described in this chapter will enable you to store data between program invocations and to process data from other programs. Opening Files You can open files with the open function, which lives in the io module but is automatically imported for you. It takes a file name as its only mandatory argument and returns a file object. Assuming that you have a text file (created with your text editor, perhaps) called somefile.txt stored in the current directory, you can open it like this: >>> f = open('somefile.txt') You can also specify the full path to the file, if it’s located somewhere else. If it doesn’t exist, however, ...
In this blog, you can learn new python 3.8 lessons and latest frameworks.