1.File类:对硬盘上的文件和目录进行操作的类. File类是文件和目录路径名抽象表现形式 构造函数: 1) File(String pathname) Creates a new File instance by converting the given pathname string into an abstract pathname. 2)File(File parent, String child) Creates a new File i…
笔记: python if not 判断是否为None的情况 if not x if x is None if not x is None if x is not None`是最好的写法,清晰,不会出现错误,以后坚持使用这种写法. 使用if not x这种写法的前提是:必须清楚x等于None, False, 空字符串"", 0, 空列表[], 空字典{}, 空元组()时对你的判断没有影响才行 链接:https://www.cnblogs.com/chenya/p/4218761.…
题目描述: 第一次提交: class Solution: def spiralOrder(self, matrix: List[List[int]]) -> List[int]: j,x = 0,1 l = [] if matrix==[]: return [] m = len(matrix) n = len(matrix[0]) while x<=n*m: for i in range(j,n-j): l.append(matrix[j][i]) x += 1 for i in range(…
b站网址https://www.bilibili.com/video/av17188299/?p=2 1. Mother Teresa, who received a Nobel Peace Prize for her work on behalf of the poor dies in Calcutta, India--she was 87 years old. -Calcutta 加尔各答 2. --Jerry, what time do you have?--I have 5 o'cloc…
题目: 第一次提交; class Solution: def searchInsert(self, nums: List[int], target: int) -> int: for i in range(len(nums)): if nums[i] >= target : return i if i == (len(nums)-1) and nums[i]<target: return i+1 法二: class Solution: def searchInsert(self, num…
题目: 第一次提交: class Solution: def strStr(self, haystack: str, needle: str) -> int: if not len(needle): return 0 for i in range(len(haystack)): if i+len(needle)<=len(haystack): if haystack[i:(i+len(needle))]==needle: return i return -1 方法二: Sunday 平均O(N…
题目: 第一次提交: class Solution: def removeElement(self, nums, val: int) -> int: for i in range(len(nums)-1,-1, -1):#此处中间为range(,中间值为-1,) if nums[i] == val: nums.remove(nums[i])#或nums.pop(i) return len(nums) 方法二:正序 class Solution: def removeElement(self, n…