ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Regular expressions
    Python/Py4e from Coursera 2020. 10. 6. 20:24

    Today i learnt about regular expressions. Especially the main point was extracting data. 

    i want to tell you what i learnt today as reviewing the whole thing .

     

    1. In a wild point of view, there are two parts in regular expressions, which are research and extraction.

    What research does is to literally find a string what i want to know if there is the string in lines. And, What extration does is that it extracts a string as using regular expressions.

     

    2. How to use both ?

     1) Before we use both, because they are libraries, you need to make a statement saying "import re"

     2) Then, if you want to use search, you can type as this shape "re.search()". Inside the parentheses, put two things. The first is what you want to search, using double quotes like ' ', " " . The second is where you find the strings, meaning that it usually uses when you read a file, so you open the file, and read lines through a for loop, then you read each line of the file.

     3) If you want to use extraction, you can use this as saying "re.findall()". How the method functions is that at first, find a string what you want, and then the part is printed as a list.

     

     

    'Python > Py4e from Coursera' 카테고리의 다른 글

    What i learnt today is ...  (0) 2020.10.05
    Finish the second chapter !  (0) 2020.10.04
Designed by Tistory.