我想把julia代码写在.py文件中,运行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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
652 次 |
| 最近记录: |