gpt4 book ai didi

python - 如何使用 Rust 使用默认程序启动任何文件(如 Python 的 `os.startfile()` )

转载 作者:行者123 更新时间:2023-12-04 01:02:55 29 4
gpt4 key购买 nike

有没有等同于python中的os.startfile()的rust方法。例如,我需要使用 Rust 启动一个“mp3 文件”。在 Python 中它是 os.startfile('audio.mp3')。这将打开默认媒体播放器并开始播放该文件。我需要用 Rust 语言做同样的事情。

最佳答案

Python 的os.startfile() 函数只能在Windows 上使用,它只是ShellExecuteW() 的包装器。在 Windows API 中。你可以call this function via the winapi crate .

一个更简单、更便携的解决方案是使用 open crate .

关于python - 如何使用 Rust 使用默认程序启动任何文件(如 Python 的 `os.startfile()` ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67599109/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com