是否可以从Julia调用Python函数并返回其结果?

BL_*_*L_7 1 python julia

我正在使用Python从网上抓取数据.我想用这些数据在Julia中运行计算.

是否可以在Julia中调用该函数并返回其结果,或者我最好只是导出为CSV并以这种方式加载数据?

Mat*_* B. 15

绝对.请参阅PyCall.jl.

julia> using PyCall

julia> @pyimport bs4

julia> @pyimport requests

julia> r = requests.get("https://stackoverflow.com/questions/46638265");

julia> soup = bs4.BeautifulSoup(r[:content]);

julia> soup[:title][:string]
"Is it possible to call a python function from Julia and return its result - Stack Overflow"

julia> soup[:select](".answercell p")[1][:text]
"Absolutely.  See PyCall.jl."
Run Code Online (Sandbox Code Playgroud)

  • 喜欢你正在抓住这个问题!:) (5认同)