在python中,webbrowser这个模块提供了一个抽象的接口,用来展现基于web的文档给客户。简单的说,他会去调用你机子默认的浏览器,展示你传进去的url。当调用浏览器失败的时候,会触发webbrowser.Error的错误。模块定义的方法如下:

webbrowser.open(url[,new=0[,autoraise=True]])

Displayurlusing the default browser. Ifnewis 0, theurlis opened in the same browser window if possible. Ifnewis 1, a new browser window is opened if possible. Ifnewis 2, a new

browser page (“tab”) is opened if possible. IfautoraiseisTrue, the window is

raised if possible (note that under many window managers this will occur

regardless of the setting of this variable).

Note that on some platforms, trying to open a filename using this function,

may work and start the operating system’s associated program. However, this is

neither supported nor portable.

Changed in version 2.5:newcan now be 2.

webbrowser.open_new(url)

Openurlin a new window of the default browser, if possible,

otherwise, openurlin the only browser window.

webbrowser.open_new_tab(url)

Openurlin a new page (“tab”) of the default browser, if possible,

otherwise equivalent toopen_new().

New in version

2.5.

webbrowser.get([name])

Return a controller object for the browser typename. Ifnameis empty, return a controller for a default browser appropriate to

the caller’s environment.

webbrowser.register(name,constructor[,instance])

Register the browser typename. Once a browser type is registered,

theget()function can return a controller for that

browser type. Ifinstanceis not provided, or isNone,constructorwill be called without parameters to create an instance

when needed. Ifinstanceis provided,constructorwill never

be called, and may beNone.

This entry point is only useful if you plan to either set theBROWSERvariable or callget()with a nonempty argument matching the name of a

handler you declare.

示例:

url = 'http://www.python.org/'

# Open URL in a new tab, if a browser window is already open.

webbrowser.open_new_tab(url + 'doc/')

# Open URL in new window, raising the window if possible.

webbrowser.open_new(url)

通过简单的几句,就可以调用本地浏览器展示基于web的文本。

python webbrowser安装_python模块webbrowser相关推荐

  1. 查看python内部模块命令,内置函数,查看python已经安装的模块命令

    查看python内部模块命令,内置函数,查看python已经安装的模块命令 可以用dir(modules) 或者用 pip list 或者用 help('modules') 或者用 python -m ...

  2. 软件包ipython没有可安装候选_解决python 自动安装缺少模块的问题

    解决python 自动安装缺少模块的问题 场景 我写个脚本给别人用,但是这个脚本中包含了一个第三方库. 当然对方执行的时候就会提示缺少,能否让python自动安装呢? 解决 try: import r ...

  3. python 怎么安装电脑摄像头模块_Python模块及安装

    Python模块及安装 09-Python模块及安装思维导图下载 1.模块的使用及安装 <1>Python中的模块 在Python中有一个概念叫做模块(module),这个和C语言中的头文 ...

  4. python模块安装_Python模块安装问题

    目录 ------------------------------------------------------ 安装工具setuptools(及基本使用) 安装工具pip(及基本使用)(plus: ...

  5. python bs4 安装_Python安装Bs4的多种方法

    安装方法一: ①进入python文件夹执行指令(前提是支持pip指令): pip3 install Beautifulsoup4 ②回车待安装完成,如果出现以下红框中内容,即代表安装成功 ③验证是否可 ...

  6. python flask安装_python flask安装和命令详解

    Flask Web开发实战学习笔记 Flask简介 Flask是使用Python编写的Web微框架.Web框架可以让我们不用关 心底层的请求响应处理,更方便高效地编写Web程序.因为Flask核心简 ...

  7. python安装pygame模块_windows下 python 如何安装pygame模块

    本机系统:win7,Pyhon版本: 3.6.0 1. 安装下载python 官网 https://www.python.org/ 下载地址 https://www.python.org/downlo ...

  8. Python离线安装PIL 模块(pillow、沙箱、照相)

    python的库一般都用pip安装. 但是有时候也会出现在线安装失败的情况,如下图安装PIL模块时报错: 这时候可以采取离线安装的方式: 一.首先下载离线安装包 PIL官方版不支持py3,不过有非官方 ...

  9. python怎么安装turtle_Turtle模块安装

    python3.7.0中,Turtle海龟模块安装指南 1.查看是否安装turtle 查看Python中已经安装的模块,在cmd命令行输入:pip3 list 如果没有找到turtle,就进行安装 D ...

最新文章

  1. 电脑下载python教程-python教程pdf下载
  2. 来自一年的程序员的困惑
  3. 018_Spring+ActiveMQ(消息中间件)
  4. java执行linux脚本 并返回其执行结果
  5. 继续完善掼蛋游戏 其次说说朋友的情况
  6. WebFlux响应式编程基础之 2 函数式编程 工具jclasslib bytecode viewer
  7. Spring MVC拦截器(Interceptor)的配置及使用
  8. i5 9400f和GTX1660能玩战地5吗?
  9. 2017交大计算机专业分数线,2017上海交大录取分数线历年录取分(2)
  10. ubuntu 18.04忘记登录密码的破解方法
  11. 任天堂xci文件提取romfs
  12. 制造企业年终仓库盘点有哪些好的方法
  13. mkv格式怎么转换成mp4?
  14. Silvaco TCAD仿真学习Lesson2——Athena仿真
  15. java打印长方形、平行四边形、三角形、菱形
  16. 大一寒假培训(三)——暴力枚举及妙用
  17. 警告 warning: NUL charactor seen; rest of line ignored
  18. 乖乖,很想读给你的诗--[人生]
  19. Iterator<E>
  20. 土建翻模怎么自动【生成构造柱】呢?

热门文章

  1. 夺命雷公狗—玩转SEO---56---query需求分析与搜索意图研究
  2. 银色情人节,TcaplusDB数据库与你一起过节!
  3. 虚拟网络主流架构(让虚拟机上网的三种方案)
  4. jmeter-http代理服务器,录制脚本,抓包-包含模式,过滤指定域名(url)数据
  5. 2022Android网络编程总结篇,开发者必备的顶级Android开发工具
  6. Hacker‘s Delight中的Trick
  7. fault.java.lang_如何解决mapping exception to axisfault
  8. 什么是代理服务器?它有哪些分类?
  9. IE7.0 中设置选项卡中的在新的窗口中打开网页(注册表)
  10. 基于java开发的健身器材电商管理系统.rar(含项目源码前后端项目)