python if else单行
a = [1,2,3]
b = a if len(a) != 0 else ""
b = [1,2,3]#结果
a = []
b = a if len(a) != 0 else ""
b = ""#结果
文章标签 if-else-单行 python 文章分类 Python 后端开发
a = [1,2,3]
b = a if len(a) != 0 else ""
b = [1,2,3]#结果
a = []
b = a if len(a) != 0 else ""
b = ""#结果
Go by Example if-else语句
了解了如何编写第一个Python 程序,接下来,我们来学习更多的Python 知识。本篇内容,我们来介绍一些Python 基础概念。1,注释每种编程语言中都有注释,代码注释的主要作用是解释某段代码的含义,以供其他维护人员参考。Python 解释器在遇到注释时,会将其忽略,而不会当做代码来执行。注释可分为单行注释和多行注释。Python 中使用符号# 进行单行注释,使用三单引号'''
一.基本语句注释: # 单行注释 """多行注释 """print (" ") 输出函数基本运算符: + - * / //(取整) %(取余) **(幂运算)变量的定义: 变量名 = 值 (每个变量使用前都必须赋值,变量在赋值以后才会被创造,定义时不需要指定变量类型)type( ) 查看变量类型函数input( ) 变量输入函数 用法举例: a = input(“输入数字:”) 输入的任
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M