[英]how to use function from another file in python
I made a file containing a scraping function using Python.我使用 Python 制作了一个包含抓取功能的文件。 I want to import this scraping file from another file and use it, what should I do?
我想从另一个文件中导入这个抓取文件并使用它,我该怎么办?
scrap.py废料.py
def scraper(url):
list = []
...
return list
def filter(list):
...
return list
def controller(list):
return filter(scraper(url))
another.py另一个.py
import scrap
#scrap.controller('www...')
should i change code in scrap.py?我应该更改 scrap.py 中的代码吗? if it is, how to change?
如果是,如何改变?
Place two files( scrap.py
, another.py
) in the same directory.将两个文件(
scrap.py
, another.py
)放在同一目录中。 That's all.就这样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.