1. To open a file pass file path and access mode r to the open() function. The access mode specifies the operation you wanted to perform on the file, such as reading or writing. For example, fp= open(r'File_Path', 'r') to read a file. 2. Create a list with the number of each line in a text file to read. For example, line_numbers = [4, 7]. Here we are reading lines 4 and 7. 3. After reading line 4 and 7 we will store result it in a list variable.
確定! 回上一頁