代码
- 变量为字符串类型(优雅的方式)
1 | if not string: |
- 变量类型不确定
1 | if string == '': |
参考
- https://docs.python.org/2/library/stdtypes.html#truth-value-testing
- http://stackoverflow.com/questions/9573244/most-elegant-way-to-check-if-the-string-is-empty-in-python
1 | if not string: |
1 | if string == '': |