close

[Solved] NameError: name ‘re’ is not defined

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error NameError: name ‘re’ is not defined in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How NameError: name ‘re’ is not defined Error Occurs?

Today I get the following error NameError: name ‘re’ is not defined in python.

How To Solve NameError: name ‘re’ is not defined Error ?

  1. How To Solve NameError: name 're' is not defined Error ?

    To Solve NameError: name 're' is not defined Error You left the () off after read at the end of the line. So currently webpage is a reference to the .read method, it's not the result of the .read() call.

  2. NameError: name 're' is not defined

    To Solve NameError: name 're' is not defined Error You left the () off after read at the end of the line. So currently webpage is a reference to the .read method, it's not the result of the .read() call.

Solution 1

As well as the missing import re, your program has another error. In

webpage = urlopen('http://feeds.huffingtonpost.com/huffingtonpost/LatestNews').read

You left the () off after read at the end of the line. So currently webpage is a reference to the .read method, it’s not the result of the .read() call.

Solution 2

You need to import regular expression module in your code

import re
re.compile('<title>(.*)</title>')

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read