我有以下代码:
class Solution:
def three_sum(self, nums: List[int]) -> List[List[int]]:
nums.sort()
output_set: set = set() #Notice
if len(nums) < 3:
return []
for i in range(len(nums)-2): #at least 2 element left
sub_nums = nums[i+1:]
sub_target = 0 - nums[i]
logging.warning(f"sub_target: {sub_target}")
two_sum_output = self.two_sum(sub_nums, sub_target)
logging.warning(f"two_sum_output: {two_sum_output}")
if two_sum_output != None:
temp = { (nums[i],) + tuple(l) for l in two_sum_output }
output_set.update(temp)
output = [ list(t) for t in output_set] #conver to list
logging.warning(f"final output count: {len(output)}:\n {output}")
return output
我想用 , 删除logging
行
grep
他们能
$ grep "logging" twoSum.py
import logging
# logging.disable(level=CRITICAL)
logging.basicConfig(level=logging.debug,
logging.info(f"Start of twoSum Process {os.getpid()}")
# logging.debug(f"{ps.stdout.decode('utf-8')}")
logging.info(f'find: {find} ')
logging.info(f"j: {j}")
怎么可能删除它们?
使用
grep -v
并复制到另一个文件笔记: