自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(42)
  • 收藏
  • 关注

原创 Django数据库 makemigrations 有变化但是 migrate时未变动

写models.py时缺少了一个 verbose_name,导致数据库出现问题,整了很久,摸索出重新建立数据库的方法: 首先删除每个app中的migrations中的除了init.py的文件,在数据库中清空所有的表,然后执行migrate,这时会自动生成系统默认的那些表,然后执行makemigrations,再执行migrate 如果只是众多应用中的一个出了问题的话,删除与之相关的表,然后进入d

2017-05-23 18:55:44 5206

原创 VirtualBox 启动虚拟机失败 - NtCreateFile(\Device\VBoxDrvStub)

NtCreateFile(\Device\VBoxDrvStub) failed: 0xc000000034STATUS_OBJECT_NAME_NOT_FOUND (0 retries) (rc=-101)Make sure the kernel module has been loaded successfully.解决方案:卸载之后使用管理员权限运

2017-05-16 00:16:50 7590

转载 虚拟机vmnet0、vmnet1和vmnet8的区别 虚拟网卡概述

vmnet0,实际上就是一个虚拟的网桥vmnet0,实际上就是一个虚拟的网桥,这个网桥有很若干个端口,一个端口用于连接你的Host,一个端口用于连接你的虚拟机,他们的位置是对等的,谁也不是谁的网关。所以在Bridged模式下,你可以让虚拟机成为一台和你的Host相同地位的机器。vmnet1,这是一个Host-Only网络模式vmnet1,这是一个Host-Only网络模式,

2017-05-15 19:37:02 6518

原创 504. Base 7

def convertTo7(self, num): if num < 0: return '-' + self.convertTo7(-num) if num < 7: return str(num) return self.convertTo7(num // 7) + str(num % 7)递归的方法def convertTo7(self, num): if n

2017-05-10 00:00:58 197

原创 python ord() chr() unichr() 函数

ord()函数以一个字符(长度为1的字符串)作为参数,返回对应的ASCII数值,或者Unicode数值,如果所给的Unicode字符超出了你的Python定义范围,则会引发一个TypeError的异常。>>>ord("a")>97chr()函数用一个范围在range(256)内的(就是0~255)整数作参数,返回一个对应的字符。unichr()跟它一样,只不过返回的是Unicode字符.>>>ch

2017-05-07 23:00:33 601

原创 171. Excel Sheet Column Number

class Solution(object): def titleToNumber(self, s): """ :type s: str :rtype: int """ sum = 0 n = len(s) for i in range(n)[::-1]:

2017-05-07 22:56:30 195

原创 python min()函数需要注意的一些小点

min函数的一些用法:>>> min([] or [-1] or [-2])> -1>>> min(1,2,3 or -1)> 1>>> min( or -1)> 报错>>> min(1)>'int' object is not iterable首先:min()方法使用的对象需要是iterable的,list,set等; 另外,or在min中的意义,第一个例子中,min的对象为空,所

2017-05-07 22:12:31 2206

原创 387. First Unique Character in a String

# return min(s.find(c) for c in s if s.count(c) == 1 or -1) # return min([s.find(c) for c in s if s.count(c) == 1] or [-1])return min([s.find(c) for c in string.ascii_lowercase if s.count(c)==1] or [

2017-05-07 22:11:44 216

原创 关于java 的InputStream和OutputStream的理解

关于InputStream和OutputStream的输入输出方向的理解InputStream输入类,首先需要读取的内容转化成输入流,再从它那里进行读取,先关联源;之后过程中关联目的,这样形成了流; 把要读取的内容输入到输入流,再从输入流进行读取,所以是read()OutputStream输出类,首先需要与写入的目的地相关联,然后通过它进行写入,首先关联的是流的目的;之后的过程中再关联源,这样形成

2017-05-07 18:19:22 6168

原创 pycharm 主题 theme 设置 调整 仿sublime

首先选择整体的theme在font中scheme选择monokai,但是并不能进行更改,比如字体大小,如果要进行进一步地调整,选择save as,这样就可以在这个新的备份上进行修改了在monokai基础上(也就是另存为的monokai copy)做一些调整,比如更改大小字号,间距等调整关键字的颜色在python选项中选择monokai copy,然后调整

2017-05-06 15:09:30 40089

原创 404. Sum of Left Leaves

class Solution(object): def sumOfLeftLeaves(self, root): """ :type root: TreeNode :rtype: int """ # def findleft(root): # if root: #

2017-05-05 23:33:57 290

原创 349. Intersection of Two Arrays

https://leetcode.com/problems/intersection-of-two-arrays/#/description 先将两个list中的重复元素去掉,即使用set(list)去重,再转化为list即可,这时list中的元素都是没有重复的class Solution(object): def intersection(self, nums1, nums2):

2017-05-05 22:28:48 189

原创 383. Ransom Note

原本打算使用list的<运算符,因为set具有比较两个set是否是包含关系的<运算符,但是list的<运算符貌似只能比较list中的元素的个数的多少class Solution(object): def canConstruct(self, ransomNote, magazine): """ :type ransomNote: str :ty

2017-05-05 21:51:35 197

原创 453. Minimum Moves to Equal Array Elements

class Solution(object): def minMoves(self, nums): """ :type nums: List[int] :rtype: int """ s = sum(nums) minNum = min(nums) l = len(nums)

2017-05-05 21:28:35 200

原创 455. Assign Cookies

超时了class Solution(object): def findContentChildren(self, g, s): """ :type g: List[int] :type s: List[int] :rtype: int """ count = 0 k=[] //已

2017-05-05 21:02:11 171

原创 167. Two Sum II - Input array is sorted

class Solution(object): def twoSum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ d = dict() fo

2017-05-05 20:44:57 184

原创 506. Relative Ranks

class Solution(object): def findRelativeRanks(self, nums): """ :type nums: List[int] :rtype: List[str] """ sort = sorted(nums,reverse=True) medals =

2017-05-05 15:37:04 178

原创 python dict 字典 总结

创建字典: d = {} d= dict()初始化: d = {"a":"apple","b":"banana"}d = dict(a="apple",b="banana")>>>d = dict.fromkeys(['a','b']) >>>d = {}.fromkeys(['a','b']) {'a':None,'b':None}>>>d = dict(zip(["a","b"],["

2017-05-05 15:15:09 368

原创 530. Minimum Absolute Difference in BST

欢迎关注我的leetcode习题解答集,不断完善中,希望可以带给你帮助,共同进步 leetcode习题解答集可以对照563. Binary Tree Tilt超时了,思路是把树种的值全部取出来放在list中,然后处理class Solution(object): def getMinimumDifference(self, root): """ :typ

2017-05-05 12:32:35 236

原创 563. Binary Tree Tilt **

欢迎关注我的leetcode习题解答集,不断完善中,希望可以带给你帮助,共同进步 leetcode习题解答集题意理解:以[1,2,3,4,null,5]为例,在计算点1的倾斜度时,不是3-2=1,而应该是1的左子树的全部之和减去1的右子树的全部之和,即3+5-(2+4)=2,然后加上2的倾斜度4,3的倾斜度5,也就是11开始的时候是这么写的(错误的):class Solution(object):

2017-05-05 11:50:52 465

转载 python的取整函数:向上取整,向下取整,四舍五入取整

#encoding:utf-8import math#向上取整print "math.ceil---"print "math.ceil(2.3) => ", math.ceil(2.3)print "math.ceil(2.6) => ", math.ceil(2.6)#向下取整print "\nmath.floor---"print "math.floor(2.3) => ", mat

2017-05-05 10:26:33 118144

原创 492. Construct the Rectangle

class Solution(object): def constructRectangle(self, area): """ :type area: int :rtype: List[int] """ l = [] i = math.floor(math.sqrt(area))

2017-05-05 10:23:25 318

原创 283. Move Zeroes

欢迎关注我的leetcode习题解答集,不断完善中,希望可以带给你帮助,共同进步 leetcode习题解答集class Solution(object): def moveZeroes(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, mod

2017-05-05 00:44:22 180

原创 258. Add Digits

循环class Solution(object): def addDigits(self, num): """ :type num: int :rtype: int """ while num >= 10: temp = 0 while num:

2017-05-05 00:34:30 158

原创 226. Invert Binary Tree

递归class Solution(object): def invertTree(self, root): """ :type root: TreeNode :rtype: TreeNode """ if root.left != None or root.right!= None: t

2017-05-05 00:05:41 224

原创 371. Sum of Two Integers

class Solution(object): def getSum(self, a, b): """ :type a: int :type b: int :rtype: int """ # 32 bits integer max MAX = 0x7FFFFFFF

2017-05-04 19:59:09 226

原创 389. Find the Difference

class Solution(object): def findTheDifference(self, s, t): """ :type s: str :type t: str :rtype: str """ dic ={} for it in s: dic

2017-05-04 00:32:11 184

原创 521. Longest Uncommon Subsequence I

For strings A, B, when len(A) > len(B), the longest possible subsequence of either A or B is A, and no subsequence of B can be equal to A. Answer: len(A).When len(A) == len(B), the only subsequence of

2017-05-04 00:21:49 191

原创 104. Maximum Depth of Binary Tree

递归的方法class Solution(object): def maxDepth(self, root): """ :type root: TreeNode :rtype: int """ if root is None: return 0 else:

2017-05-04 00:02:15 240

原创 448. Find All Numbers Disappeared in an Array

class Solution(object): def findDisappearedNumbers(self, nums): """ :type nums: List[int] :rtype: List[int] """ return[i for i in range(1,len(nums)+1) if i n

2017-05-03 23:16:00 159

原创 520. Detect Capital

class Solution(object): def detectCapitalUse(self, word): """ :type word: str :rtype: bool """ word_temp = word[1:]; if (word.lower() == word):

2017-05-03 23:08:47 243

原创 136. Single Number

0异或任何数字都是数字本身,相同的数字异或为0,同时异或有交换律,不因数字的顺序改变,所有相同的经过异或均变为0,和唯一的一个数字异或后就为那个数字。class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int

2017-05-03 23:04:07 234

原创 485. Max Consecutive Ones

class Solution(object): def findMaxConsecutiveOnes(self, nums): """ :type nums: List[int] :rtype: int """ max_count = 0 count = 0 for num in

2017-05-03 22:59:04 159

原创 463. Island Perimeter

每一个陆地单元格的周长为4,当两单元格上下或者左右相邻时,令周长减2,每有一个相邻的方块,边就减少两条,判断好边界就没问题了。class Solution(object): def islandPerimeter(self, grid): """ :type grid: List[List[int]] :rtype: int "

2017-05-03 22:47:17 187

原创 496. Next Greater Element I

Suppose we have a decreasing sequence followed by a greater number. For example [5, 4, 3, 2, 1, 6] then the greater number 6 is the next greater element for all previous numbers in the sequence. We us

2017-05-03 22:29:15 167

原创 412. Fizz Buzz

class Solution(object): def fizzBuzz(self, n): """ :type n: int :rtype: List[str] """ list=[] for i in range(1,n+1): list.append(str(i))

2017-05-03 21:53:17 179

原创 500. Keyboard Row

直观做法class Solution(object): def findWords(self, words): """ :type words: List[str] :rtype: List[str] """ list=[] strings=['qwertyuiop','asdfghjkl','

2017-05-03 21:31:00 165

原创 541. Reverse String II

class Solution(object): def reverseStr(self, s, k): """ :type s: str :type k: int :rtype: str """ def reverse(string): return string[::-1

2017-05-03 21:01:54 172

原创 557. Reverse Words in a String III

class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str """ list = s.split(" ") for i in range(len(list)): list[i]

2017-05-03 19:10:22 146

转载 [待完善]Python中zip()函数用法举例

参考

2017-05-03 17:52:29 427

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除