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

时间:2017-10-09 03:03:54

标签: python julia

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

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

2 个答案:

答案 0 :(得分:15)

绝对。请参阅PyCall.jl

app.exe

答案 1 :(得分:1)

不是您的问题的答案,但是用Julia本身刮擦网络很容易

using Gumbo
using Cascadia
using Cascadia: matchFirst
using HTTP

r = HTTP.get("https://stackoverflow.com/questions/46638265")
page = parsehtml(String(r.body))
julia> matchFirst(sel"title", page.root) |> nodeText
"Is it possible to call a Python function from Julia and return its result? - Stack Overflow"

julia> eachmatch(sel".answercell p", page.root) .|> nodeText
2-element Array{String,1}:
 "Absolutely.  See PyCall.jl."
 "Not an answer to your question, but it is rather easy to scrape web in Julia itself"