网站首页 站内搜索

搜索结果

查询Tags标签: self,共有 3605条记录
  • Python循环替换字典中的None

    循环替换字典中的None值:class Gsxt:""""""def __init__(self, company_name, city):passdef replace_dict(self, tmp_dict_or_list):if isinstance(tmp_dict_or_list, dict):for k, v in tmp_dict_or_list.items():if isinstance(v, (dic…

    2021/7/29 12:05:52 人评论 次浏览
  • 最小的k个数-剑指offer40-python

    算法思想 排序思想比较简单,时间复杂度是O(nlogn),代码不展示了。 利用类似快排的思想,可以使时间复杂度为O(n)。 python class Solution:def partition(self, arr, left, right):i = left - 1pviot = arr[right]for j in range(left, right):if arr[j] < pviot:i +…

    2021/7/29 11:35:40 人评论 次浏览
  • 最小的k个数-剑指offer40-python

    算法思想 排序思想比较简单,时间复杂度是O(nlogn),代码不展示了。 利用类似快排的思想,可以使时间复杂度为O(n)。 python class Solution:def partition(self, arr, left, right):i = left - 1pviot = arr[right]for j in range(left, right):if arr[j] < pviot:i +…

    2021/7/29 11:35:40 人评论 次浏览
  • [LeetCode] 25. Reverse Nodes in k-Group_Hard tag: Linked List

    Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes, in…

    2021/7/29 9:06:10 人评论 次浏览
  • [LeetCode] 25. Reverse Nodes in k-Group_Hard tag: Linked List

    Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes, in…

    2021/7/29 9:06:10 人评论 次浏览
  • slicer学习笔记(四)

    MyFirstModule 暂时可以通过的测试程序: import os import unittest import logging import vtk, qt, ctk, slicer from slicer.ScriptedLoadableModule import * from slicer.util import VTKObservationMixin# # MyFirstModule #class MyFirstModule(ScriptedLoadableM…

    2021/7/29 6:09:17 人评论 次浏览
  • slicer学习笔记(四)

    MyFirstModule 暂时可以通过的测试程序: import os import unittest import logging import vtk, qt, ctk, slicer from slicer.ScriptedLoadableModule import * from slicer.util import VTKObservationMixin# # MyFirstModule #class MyFirstModule(ScriptedLoadableM…

    2021/7/29 6:09:17 人评论 次浏览
  • [LeetCode] 5. Longest Palindromic Substring _Medium tag: Two pointers

    Given a string s, return the longest palindromic substring in s.Example 1: Input: s = "babad" Output: "bab" Note: "aba" is also a valid answer.Example 2: Input: s = "cbbd" Output: "bb"Example 3: Input:…

    2021/7/29 6:07:53 人评论 次浏览
  • [LeetCode] 5. Longest Palindromic Substring _Medium tag: Two pointers

    Given a string s, return the longest palindromic substring in s.Example 1: Input: s = "babad" Output: "bab" Note: "aba" is also a valid answer.Example 2: Input: s = "cbbd" Output: "bb"Example 3: Input:…

    2021/7/29 6:07:53 人评论 次浏览
  • [Leetcode] 543. Diameter of Binary Tree_Easy Tag: DFS

    543. Diameter of Binary TreeEasy 5310325Add to ListShareGiven the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or m…

    2021/7/29 6:05:56 人评论 次浏览
  • [Leetcode] 543. Diameter of Binary Tree_Easy Tag: DFS

    543. Diameter of Binary TreeEasy 5310325Add to ListShareGiven the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or m…

    2021/7/29 6:05:56 人评论 次浏览
  • SQLAlchemy 事务

    定义两个表User和Person, 先插入第一个表,抛出异常,在插入第二个表 UserModelfrom sqlalchemy import Column, Integer, VARCHAR from sqlalchemy.orm import declarative_baseBase = declarative_base()class User(Base):__tablename__ = usersid = Column(Integer, p…

    2021/7/29 2:35:57 人评论 次浏览
  • SQLAlchemy 事务

    定义两个表User和Person, 先插入第一个表,抛出异常,在插入第二个表 UserModelfrom sqlalchemy import Column, Integer, VARCHAR from sqlalchemy.orm import declarative_baseBase = declarative_base()class User(Base):__tablename__ = usersid = Column(Integer, p…

    2021/7/29 2:35:57 人评论 次浏览
  • Python 抛自定义异常

    自定义异常,抛自定义异常,捕获异常,打印异常堆栈import tracebackclass UserNameTooLong(Exception):def __init__(self, long):self.long = longdef __str__(self):return user name length is + str(self.long) + " too long"def raise_error():s = input…

    2021/7/29 1:06:00 人评论 次浏览
  • Python 抛自定义异常

    自定义异常,抛自定义异常,捕获异常,打印异常堆栈import tracebackclass UserNameTooLong(Exception):def __init__(self, long):self.long = longdef __str__(self):return user name length is + str(self.long) + " too long"def raise_error():s = input…

    2021/7/29 1:06:00 人评论 次浏览
扫一扫关注最新编程教程