LearnDevOps
  • Home
  • About Me
  • Categories
  • Tags
  • Archives

python-tips

b = 0 a = False if b else True print(a) True

等同于

if b == False: a = True else: a = False

result1 = 0 result2 = 1

a = result1 if True else result2 a

b = result1 if False else result2

单行 if else

语法:值1:result1,值2:result2,if:条件 当条件为true时,结果为值1,条件为False时 结果为值2

小写字母转换为大写字母 `str.upper()`` #方法将字符串中的小写字母转为大写字母


Published

5月 11, 2016

Category

python

Tags

  • python 7
  • Powered by Pelican. Theme: Elegant by Talha Mansoor