如何在python中打开Goog​​le Chrome

时间:2020-06-16 11:29:41

标签: python-3.x

我尝试做各种python代码,但在我的PC上找不到任何有效的代码。

def UI():
os.system('cls' if os.name == 'nt' else 'clear')
choice1=input("Pick a program: ")
if choice1=='Google':   
 ('https://www.google.com/')

这就是我想出的一切

如果有人有任何答案,请告诉我

2 个答案:

答案 0 :(得分:2)

在Windows中使用os.system('start chrome')os.system('start chrome {}'.format(site)),在Linux中使用os.system('google-chrome')os.system('google-chrome {}'.format(site)),其中site是您要查找的网站的URL。< / p>

答案 1 :(得分:1)

<!--maven connect nexus need user and password-->
<settings>
    <servers>
        <server>
            <id>ossrh</id>
            <username></username>
            <password></password>
        </server>
    </servers>

    <profiles>
        <profile>
            <id>ossrh</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <gpg.passphrase>gpg.passphrase
                </gpg.passphrase>
            </properties>
        </profile>
    </profiles>
</settings>

您可以使用Chrome的路径调用get()。下面是一个示例-用适合您平台的正确路径替换chrome_path。