小编har*_*eyD的帖子

在 Python 中使用 Webbrowser 模块打开选项卡

我正在使用 webbrowser 模块编写 Python 脚本以自动打开所需的网页。
我面临的问题是我只能在不同的浏览器窗口上打开网页,而不能在不同选项卡上的同一个浏览器窗口上打开网页。

下面是我正在使用的代码。

#! /usr/bin/python -tt

import webbrowser

def main():

    webbrowser.open('url1')
    webbrowser.open('url2')
    webbrowser.open('url3')
if __name__ == '__main__':
    main()
Run Code Online (Sandbox Code Playgroud)

我想在单独的选项卡上的同一个 Web 浏览器窗口上打开所有这些链接,而不是在不同的浏览器窗口上。谢谢 :)

python

4
推荐指数
1
解决办法
5167
查看次数

我正在尝试使用 Python 在 jar 文件中搜索“.class”文件

#! /usr/bin/python -tt
import os
def searchFile(path1,ext1,fileName1):
    pathList = []
    for root, dirs, files in os.walk(path1):
        for file in files:
            if file.endswith(ext1):
               pathList.append(os.path.join(root,file))
    print "-----The file is present under the below path------\n"
    for ele in pathList:
        if fileName1 in ele:
            print ele
def main():
    path = raw_input("Please enter the path you wish to spider. Also make sure that the files/subfolders have the correct permissions.\n")
    ext = raw_input("Enter the extension you wish to search/ find. Eg: For class files enter .class …
Run Code Online (Sandbox Code Playgroud)

python scripting jar ipython python-2.7

3
推荐指数
1
解决办法
2615
查看次数

这个变量声明如何在python中工作?

i = 0x0800
Run Code Online (Sandbox Code Playgroud)

我在这里理解的是0x0800是十六进制数,其中'0x'表示十六进制类型,后面的数字'0800'是一个2字节的十六进制数.在将其分配给变量'i'时,如果检查其类型,则会出现此错误

>>> type(i)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable
Run Code Online (Sandbox Code Playgroud)

在这里我得出'i'假设是一个int对象.当我尝试这个时,我变得更加困惑

>>> print i
2048
Run Code Online (Sandbox Code Playgroud)

究竟什么是'2048'..谁能在这里点亮一些光?

python hex python-2.7

3
推荐指数
1
解决办法
59
查看次数

标签 统计

python ×3

python-2.7 ×2

hex ×1

ipython ×1

jar ×1

scripting ×1