首页 > 技术文章 > 第一个Python程序

darcy-hui 2018-04-02 10:57 原文

Hello,Python

 

执行Python的三种方式

1、解释器(Python/Python3)

2、交互式(ipython)

3、集成开发环境(PyCharm)

 

Python源程序 -> 一个.py的文本文件

#-coding utf-8

print("Hello Python!")

 

附:第一个使用selenium模块来写的打开浏览器,搜索selenium

# coding=utf-8

from selenium import webdriver
import time

driver = webdriver.Firefox()

driver.get("https://www.baidu.com/")

driver.find_element_by_xpath("//*[@id='kw']").send_keys("selenium")
driver.find_element_by_xpath("//*[@id='su']").click()

time.sleep(2)

ele = driver.find_element_by_xpath("//*[@id='1']/h3/a/em")
if(ele == "Selenium"):
print( "test ok!")


driver.quit()

推荐阅读