如題
import get_allurls
from get_allurls import *
get_allurls是自定義的模塊,上邊兩個import都沒問題。但是現在要呼叫get_allurls模塊里的get_allurl()函式卻報錯了,報錯資訊:AttributeError: module 'get_allurls' has no attribute 'get_allurl'

這個get_allurl()在get_allurls模塊里已經定義了。
def get_allurl():
urls_inner=[]
user_in_number=int(input('請輸入生成頁數:'))
for url in generate_allurl(user_in_number):
get_url = requests.get(url)
if get_url.status_code == 200:
re_set = re.compile('"https://sh.lianjia.com/ershoufang/[0-9]+\.html"')
re_get = re.findall(re_set,get_url.text)#回傳串列值
re_get=list(set(re_get))#去除重復專案
urls_inner.append(re_get)#回傳嵌套串列
return(urls_inner)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/33150.html
