1面
1.给一个列表list1=[‘abc’,‘cd’,‘da’] 判断每一个元素是否成一个环
2. 电梯测试
3. 写sql 对1班的及格女生的平均成绩
2面
1.螺旋打印二维数组
https://blog.csdn.net/qq_26392583/article/details/61435200
2.对单词进行逆序 ’ I am student ’ 输出’ student am i’ 不能用split
https://mp.csdn.net/mdeditor/101564865#
3. 对一个ramdom函数 ,有n%概率输出a,有1-n%概率输出b,构造新的函数使得函数各有50%概率输出0,有50%概率输出1
https://blog.csdn.net/LosingCarryJie/article/details/93670122
https://blog.csdn.net/zangdaiyang1991/article/details/88768967
4. __init__ 与__new__ 各有什么作用,哪个先执行
5. 工程项目在不同的文件夹下,怎么导入包 from .xx.xxx import xxx
6. python中打印 print 1==1 与print []==[]
两者结果都是true。
扩展
a1=1 b1=5 print a1 and b1 #打印结果为5 a2=0 b2=5 print a2 and b2 #打印结果为0 a3=1 b3=5 print a3 or b3 #打印结果为1 a4=0 b4=5 print a4 or b4 #打印结果为5 a5=0 print not a5 #打印结果true a6=1 print not a6 #打印结果False |
class Solution(object): """ 输入: [ [1, 2, 3, 4], [5, 6, 7, 8], [9,10,11, 12], [13,14,15,16], ] 输出:[1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10] """ def spiralOrder(self, matrix): ret=[] if not matrix: return [] top=0 bottom =len(matrix)-1 #底部边界 left=0 right=len(matrix[0])-1 #右边界 while(True): #从左到右 for i in range(left,right+1): ret.append(matrix[top][i]) top+=1 if (left>right or top >bottom): break #无法判断哪步越界 #从上到下 for i in range(top,bottom+1): ret.append(matrix[i][right]) right-=1 if (left > right or top > bottom): break #无法判断哪步越界 #从右到左 for i in range(right,left-1,-1): ret.append(matrix[bottom][i]) bottom-=1 if (left > right or top > bottom): break # 无法判断哪步越界 #从下到上 for i in range(bottom,top-1,-1): ret.append(matrix[i][left]) left+=1 if (left > right or top > bottom): break # 无法判断哪步越界 return ret |
注意以下用法:
n=[[0]*3 for i in range(10)] print n |
打印结果,一共10个内嵌的列表,每个列表3个元素:
[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] |
上文内容不用于商业目的,如涉及知识产权问题,请权利人联系博为峰小编(021-64471599-8017),我们将立即处理