列表推导式number_list = [number for number in range(1, 7)] print(number_list) ------------------ [1, 2, 3, 4, 5, 6]列表推导式加条件语句单ifnumber_list = [number for number in range(1, 7) if number % 2 == 0] print(number_list) ------------------ [2, 4, 6]if elsenumber_list = [number**2 if number % 2 == 0 else number+10 for number in range(1, 7)] print(number_list) ----------------------- [11, 4, 13, 16, 15, 36]几个函数split()将字符串进行拆分成一个一个单词无参数a = '
函数M文件如果重复的使用一段运算,可以写一个M文件,方便后面使用调用.脚本函数建立脚本CTRL+S保存函数CTRL+S保存
一只胖橘