【坚持】Selenium+Python学习记录 DAY11

2018/06/1-2018/06/4

参考资料:

[菜鸟教程](http://www.runoob.com/python3/python3-examples.html
[Python解惑:True与False](https://foofish.net/python-true-false.html
[python里None 表示False吗?](https://www.zhihu.com/question/48707732)

学习过程中有下面一段简单的代码,但自己却还写不出精确的注释,需要把条件控制相关的内容再巩固下!!
    def __init__(self, driver, path=None):
        self.driver = driver
        self.domain = 'http://localhost/wordpress/'

        if path:
            self.url = self.domain + path
        else:
            self.url = None

        if self.url != None:
            self.navigate()

为False的几种情况
  • 布尔型,False表示False,其他为True
  • 整数和浮点数,0表示False,其他为True
  • 字符串和类字符串类型(包括bytes和unicode),空字符串表示False,其他为True
  • 序列类型(包括tuple,list,dict,set等),空表示False,非空表示True
  • None永远表示False

#No.1
path = None
if path:
    print('true')
else:
    print('false')
resut:
d:\fly\Python (master -> origin)
λ python test.py
false
    def login(self, username, password):
        self.username_text_field.send_keys(username)
        self.password_text_field.send_keys(password)
        self.login_btn.click()

        return DashboardPage(self.driver)

猜你喜欢

转载自www.cnblogs.com/flyin9/p/9135919.html