Questions With Correct Answers
Regular Expression (Definition) - ANSWERSIn computing a regular expression also
referred to as "regex" or "regexp", provides a concise and flexible means for matching
strings to text, such as particular characters, words, or patterns of characters. A regular
expression is written in a formal language that can be interpreted by a regular
expression processor.
what does the following code do?
hand = open("mbox-short.txt")
for line in hand:
->line = line.rstrip()
->if re.search("Fom:", line):
->->print(line) - ANSWERSit opens a file name mbox-short.txt and loads it to the hand
variable. then it iterates line by line. If one of the lines have "From" in it then it will be
print it out.
how does one properly make an html handler? - ANSWERSIn order to properly handle
an html page one must import the urlopen class from the urllib
and do the following:
from urllib import urlopen
html = urlopen("https://quizlet.com/216386407/edit#addRow")
How does one go about creating a beautiful soup object? - ANSWERSwe must first
import the beautiful soup class from bs4. and then we do the following
soup = BeautifulSoup(html, "html.parser")
the html argument is a specific website that we want to handle.