Home > other >  In python called a custom module to success. But can't call module inside the function how to r
In python called a custom module to success. But can't call module inside the function how to r

Time:12-05

If inscribe

The import get_allurls
The from get_allurls import *

Get_allurls is custom modules, two above the import is no problem, but now to invoke get_allurls get_allurl in the module () function is an error, an error message: AttributeError: module 'get_allurls' has no attribute' get_allurl '



The get_allurl () is already defined in the get_allurls module,

Def get_allurl () :
Urls_inner=[]
User_in_number=int (input (' please enter the generated pages: '))
For the url in generate_allurl (user_in_number) :
Get_url=requests. Get (url)
If get_url. Status_code==200:
Re_set=re.com running (' "https://sh.lianjia.com/ershoufang/[0-9] + \. HTML" ')
Re_get=re. The.findall (re_set, get_url. Text) # return list value
Re_get=list (set (re_get) # remove duplicate project
Urls_inner. Append (re_get) # return nested list
Return (urls_inner)
  • Related