摘要: 1、三元运算符 三元运算符就是在赋值变量的时候,可以直接加判断,然后赋值 格式:[on_true] if [expression] else [on_false] res = 值1 if 条件 else 值2 def my_max(x,y): m = x if x>y else y return m 阅读全文
posted @ 2018-07-25 18:28 wing1377 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 1、函数初识 函数定义了之后,可以在任何需要它的地方调用 # 函数基本格式 def mylen(): s1 = 'Hello SharkJiao' length = 0 for i in s1: length += 1 return length print('str_len:%s'%(mylen( 阅读全文
posted @ 2018-07-25 16:52 wing1377 阅读(151) 评论(0) 推荐(0) 编辑