Julia - 替代 readandwrite()
Julia - Substitute for readandwrite()
我正在尝试在 Julia 中打开并写入外部应用程序。根据我的研究,我发现曾经有一个名为 readandwrite() 的函数可以轻松完成此任务。但是,该功能似乎在早期版本中已被弃用。
我曾尝试使用 pipeline() 命令和 运行() 但收效甚微。我也尝试打开它并使用 write() 写入它,但 write 不采用 IOstream。我已经 here 并尝试了代码片段,但 none 似乎有效。其他的我不知道把文件的路径放在哪里。
p=open(pipeline(`./$xPath`; stderr=Pipe()), "r")
(Pipe(RawFD(-1) closed => RawFD(20) open, 0 bytes waiting), Process(`./$xPath`, ProcessExited(0)))
其中 xPath 是包含文件路径的字符串 ("xfoil.exe")
此代码 returns 一个未知错误,它无法生成可执行文件。
任何帮助将不胜感激,因为我在打开此文件时遇到了困难。
谢谢
运行 在 Julia 0.7 上你会收到这个警告:
julia> readandwrite(`ls`)
[ Warning: `readandwrite(::Cmd)` is deprecated in favor of `open(::Cmd, "r+").
[ You may read/write the returned process object for access to stdio.
所以替换为:
p = open(`ls`, "r+")
然后在 p
上使用 read
和 write
。
我正在尝试在 Julia 中打开并写入外部应用程序。根据我的研究,我发现曾经有一个名为 readandwrite() 的函数可以轻松完成此任务。但是,该功能似乎在早期版本中已被弃用。
我曾尝试使用 pipeline() 命令和 运行() 但收效甚微。我也尝试打开它并使用 write() 写入它,但 write 不采用 IOstream。我已经 here 并尝试了代码片段,但 none 似乎有效。其他的我不知道把文件的路径放在哪里。
p=open(pipeline(`./$xPath`; stderr=Pipe()), "r")
(Pipe(RawFD(-1) closed => RawFD(20) open, 0 bytes waiting), Process(`./$xPath`, ProcessExited(0)))
其中 xPath 是包含文件路径的字符串 ("xfoil.exe") 此代码 returns 一个未知错误,它无法生成可执行文件。 任何帮助将不胜感激,因为我在打开此文件时遇到了困难。 谢谢
运行 在 Julia 0.7 上你会收到这个警告:
julia> readandwrite(`ls`)
[ Warning: `readandwrite(::Cmd)` is deprecated in favor of `open(::Cmd, "r+").
[ You may read/write the returned process object for access to stdio.
所以替换为:
p = open(`ls`, "r+")
然后在 p
上使用 read
和 write
。