我希望能够在.py文件中编写julia代码,在运行.py文件时,julia代码也能正常通过,这可能吗?
我正在使用文本编辑器VScode、python3.10和julia1.7.2。
实际上,我知道这有点异想天开,但今天我看到python代码在julia中成功运行。所以我想知道是否可以反过来实现。
module MyModule
using PyCall
function __init__()
py"""
import numpy as np
def one(x):
return np.sin(x) ** 2 + np.cos(x) ** 2
"""
end
two(x) = py"one"(x) + py"one"(x)
end
MyModule.two(2)