在 Ruby 中打开默认浏览器 [英] Open the default browser in Ruby

查看:39
本文介绍了在 Ruby 中打开默认浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Python 中,您可以这样做:

In Python, you can do this:

import webbrowser
webbrowser.open_new("http://example.com/")

它会在默认浏览器中打开传入的url

It will open the passed in url in the default browser

是否有红宝石等价物?

推荐答案

跨平台解决方案:

首先,安装 Launchy gem:

$ gem install launchy

然后,你可以运行这个:

Then, you can run this:

require 'launchy'

Launchy.open("http://stackoverflow.com")

这篇关于在 Ruby 中打开默认浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆