class Solution:def funtcion(self,number):h=int(number/100)t=int(number%100/10)z=int(number%10)return 100*z+10*t+h
if __name__=='__main__':solution = Solution()num=123new_num = solution.funtcion(num)print("输入:{}".format(num))print("输出:{}".format(new_num))
二、合并两个数列
class Solution:def function(self,A,B):i,j=0,0lists=[]while i < len(A) and j < len(B):if A[i]<B[j]:lists.append(A[i])i+=1else:lists.append(B[j])j+=1while i < len(A):lists.append(A[i])i+=1while j < len(B):lists.append(B[j])j+=1return listsdef built(self,A,B):A.extend(B)A.sort()return A
if __name__ == '__main__':A=[1,2,3,4]B=[2,4,6,8]solution = Solution()print("输入:{}{}".format(A,B))print("输出:{}".format(solution.function(A,B)))print("使用内置函数:{}".format(solution.built(A,B)))
三、旋转字符串
class Solution:def function(self,S,offset):new_s=Sif len(new_s) > 0:offset = offset % len(new_s)temp = (new_s+new_s)[len(new_s)-offset:2*len(new_s)-offset]for i in range(len(temp)):s[i]= temp[i]return new_s
if __name__ == '__main__':s=["a","b","c","d","e","f","g"]offset = 3solution = Solution()print("输入:s={},off={}".format(s, offset))print("输入:s={}".format(solution.function(s,offset)))
报错如下:
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion1, but package-lock.json was generated for lockfileVersion2. Ill try to do my best
with it!
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! errno -4048…