小伙伴你的程序还是停留在糊墙吗?优化代码可以显示程序员的素质欧! 普及一下基础了欧: 一层for简写:y = [1,2,3,4,5,6],[(i*2) for i in y ] 会输出 [2, 4, 6, 8, 10, 12] ,标准形式为: [ 对i的操作 for i in 列表 ] 两层for循环:[对i的操作 for 单个元素 in 列表 for i in 单个元素], 例子: y_list = ['assss','dvv'] [print(i) for y in y_li…
1.不要用.size(),改用isEmpty() Using Collection.size() to test for emptiness works, but using Collection.isEmpty() makes the code more readable and can be more performant. The time complexity of any isEmpty() method implementation should be O(1) whereas so…