自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 python列表的骚操作1

list1 = ['你答错了','你答对了'][True]print(list1)

2020-01-13 21:09:36 262 1

原创 python里格式化输出字符串

之前常用的两种形式为:#格式化输出字符串a, b = 5, 6print('%d * %d = %d'%(a, b, a*b))#字符串提供的方法来完成字符串的格式化a, b = 5, 6print('{0} * {1} = {2}'.format(a,b,a*b))python3.6以后有了更加简单的方式:a, b = 5, 6print(f'{a} + {b} =...

2020-01-12 23:22:32 338

原创 python里多行缩进调整

多行向右:tab多行向左:shift+tab

2020-01-08 13:43:04 14364 2

原创 Jupyter notebook怎么显示行号

初学python时用Jupyter notebook很方便,让行号显示出来就更方便类菜单栏里 View——show line Numbers

2019-09-01 17:15:11 2968 1

原创 一行代码搞定部分网页文字无法copy

在原来url地址栏输入下面一行代码就可以右键复制了:javascript:void($={});

2019-04-23 09:28:00 575

原创 pip安装:Fatal error in launcher: Unable to create process using '"d:\software\anaconda\python.exe"

可能是安装了python2 python3版本弄得有点乱,在pip install 时总是过不去,后来查到直接python -m pip install pyspider就OK啦

2019-03-27 14:50:15 4821 2

原创 leetcode 26:Remove Duplicates from Sorted Array

class Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ length = len(nums) k = 0 if length==0:...

2019-03-21 16:03:05 105

原创 leetcode 18:4Sum

class Solution(object): def fourSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[List[int]] """ length = len(nums)...

2019-03-21 15:41:31 98

原创 leetcode 16:3Sum Closest with python

import sysclass Solution(object): def threeSumClosest(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ nums.sort()...

2019-03-21 13:49:14 124

原创 leetcode 15:3Sum with Python

class Solution(object): def threeSum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ length = len(nums) nums.sort() res ...

2019-03-21 11:18:00 149

原创 Leetcode 11.Container With Most Water with Python

class Solution(object): def maxArea(self, height): """ :type height: List[int] :rtype: int """ length = len(height) if length == 2: ret...

2019-03-19 15:44:16 93

原创 Leetcode 4.Median of Two Sorted Arrays with Python

class Solution(object): def findMedianSortedArrays(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: float """ m = len...

2019-03-19 15:42:21 103

原创 Vi/Vim 键盘图

2019-02-24 17:41:10 358

原创 leetcode 867:Transpose Matrix

https://leetcode.com/problems/transpose-matrix/class Solution: def transpose(self, A): """ :type A: List[List[int]] :rtype: List[List[int]] """ return [[...

2018-12-24 16:53:59 103

原创 leetcode 908:Smallest Range I

https://leetcode.com/problems/smallest-range-i/class Solution: def smallestRangeI(self, A, K): """ :type A: List[int] :type K: int :rtype: int """ ...

2018-12-24 16:39:29 103

原创 leetcode 700:Search in a Binary Search

https://leetcode.com/problems/search-in-a-binary-search-tree/class Solution: def searchBST(self, root, val): """ :type root: TreeNode :type val: int :rtype: Tree...

2018-12-24 16:24:37 131

原创 590. N-ary Tree Postorder Traversal

https://leetcode.com/problems/n-ary-tree-postorder-traversal/class Solution(object): def postorder(self, root): """ :type root: Node :rtype: List[int] """ ...

2018-12-05 11:29:06 132

原创 589. N-ary Tree Preorder Traversal

https://leetcode.com/problems/n-ary-tree-preorder-traversclass Solution(object): def preorder(self, root): """ :type root: Node :rtype: List[int] """ res...

2018-12-05 11:25:49 99

原创 mac os 下安装 chromedriver

去这里下载最新版本的chromedriver,前提是你的chrome也是最新的版本http://chromedriver.chromium.org/下载好了之后双击解压缩,然后在目录下打开命令行,执行$ mv chromedriver /usr/local/bin将chromedriver移动到bin目录里执行下面检验是否安装正确from selenium import...

2018-12-01 23:56:05 487

原创 Mac OS下brew的安装和使用

打开终端执行以下命令/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

2018-12-01 23:25:01 1844

原创 Python leetcode 922:Sort Array By Parity II

https://leetcode.com/problems/sort-array-by-parity-ii/ class Solution(object): def sortArrayByParityII(self, A): """ :type A: List[int] :rtype: List[int] """ ...

2018-11-01 11:35:09 237

原创 python leetcode 852.peak-index-in-a-mountain-array

https://leetcode.com/problems/peak-index-in-a-mountain-array/class Solution: def peakIndexInMountainArray(self, A): """ :type A: List[int] :rtype: int """ ...

2018-11-01 10:07:53 146

原创 leetcode 728:Self Dividing Numbers with Python

https://leetcode.com/problems/self-dividing-numbers/class Solution: def selfDividingNumbers(self, left, right): """ :type left: int :type right: int :rtype: List...

2018-10-30 11:07:58 105

原创 leetcode 561:Array Partition I with Python

https://leetcode.com/problems/array-partition-i/class Solution: def arrayPairSum(self, nums): """ :type nums: List[int] :rtype: int """ length = len(nums...

2018-10-30 11:03:35 106

原创 leetcode 617:Merge Two Binary Tree with Python

https://leetcode.com/problems/merge-two-binary-trees class Solution: def mergeTrees(self, t1, t2): """ :type t1: TreeNode :type t2: TreeNode :rtype: TreeNode ...

2018-10-30 10:59:52 132

原创 leetcode 832:Flipping an Image with Python

https://leetcode.com/problems/flipping-an-image/class Solution: def flipAndInvertImage(self, A): """ :type A: List[List[int]] :rtype: List[List[int]] """ ...

2018-10-30 10:50:13 141

原创 leetcode 657:Robot Return to Origin with Python

https://leetcode.com/problems/robot-return-to-origin/class Solution: def judgeCircle(self, moves): """ :type moves: str :rtype: bool """ list1 = [0,0] ...

2018-10-30 10:43:38 178

原创 leetcode 441:Hamming Distance with Python

https://leetcode.com/problems/hamming-distance/class Solution: def hammingDistance(self, x, y): """ :type x: int :type y: int :rtype: int """ ...

2018-10-30 10:40:17 129

原创 leetcode 905:Sort Array By Parity with Python

https://leetcode.com/problems/sort-array-by-parity/class Solution: def sortArrayByParity(self, A): """ :type A: List[int] :rtype: List[int] """ B=A.copy(...

2018-10-30 10:35:55 120

原创 leetcode 804:Submission Detail with Python

https://leetcode.com/problems/unique-morse-code-words/class Solution: def uniqueMorseRepresentations(self, words): """ :type words: List[str] :rtype: int """ ...

2018-10-30 10:33:54 158

原创 leetcode 771:Jewels and Stones with Python

https://leetcode.com/problems/jewels-and-stones/class Solution: def numJewelsInStones(self, J, S): """ :type J: str :type S: str :rtype: int """ ...

2018-10-30 10:30:11 111

原创 leetcode 821:Shortest Distance to a Character Python

https://leetcode.com/problems/shortest-distance-to-a-character/import mathclass Solution: def shortestToChar(self, S, C): """ :type S: str :type C: str :rtype: ...

2018-10-30 10:18:36 214

原创 leetcode 766 Toeplitz Matrix Python

三年前刷过leetcode,今天开始决定闲来无事继续刷着玩,并且把答案传一下博客~问题描述就不写了,贴一下链接吧https://leetcode.com/problems/toeplitz-matrix/class Solution(object): def isToeplitzMatrix(self, matrix): """ :type mat...

2018-10-29 14:55:04 207

原创 python collection.Counter() for leetcode 811 Subdomain Visit Count

在刷leetcode 811题时,单纯用字典去写会比较繁琐,看到答案里有人用到了collection模块中的Counter()类,感觉so方便啊先贴上这个题的答案:class Solution(object): def subdomainVisits(self, cpdomains): """ :type cpdomains: List[str]...

2018-10-11 17:15:04 253

原创 requests结合正则表达式爬取猫眼电影top100

import requestsimport reimport jsondef get_page(url): headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537....

2018-09-17 19:21:57 329

原创 正则表达式 ?P<name>

import re # 将匹配的数字乘以 2def double(matched): value = int(matched.group('value')) return str(value * 2) s = 'A23G4HFD567'print(re.sub('(?P&lt;value&gt;\d+)', double, s))?P&lt;value&gt;的意...

2018-08-27 10:29:21 15615 1

原创 python爬虫爬取淘宝商品的销量

代码使用过程中如果有任何问题,下方留言,我会及时解释回答;import reimport requestsimport jsondef openurl(keyword,page): params = {'q':keyword,'sort':'sale-desc','s':str(page*44)} 字典中第二项是按销量排序 headers = { 'us...

2018-08-14 16:29:52 17765 12

原创 python爬虫爬取网易云音乐的热门评论

import requestsimport jsonfrom bs4 import BeautifulSoupdef get_comments(res): comments = json.loads(res.text) hot_comments = comments['hotComments'] with open('热门评论.txt','w',encoding=...

2018-08-13 15:28:36 1527 2

原创 爬虫爬取豆瓣Top250电影 生成本地.txt文件

import requestsfrom bs4 import BeautifulSoup#request 豆瓣url,修改一下headersdef open_url(url): headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, lik...

2018-08-11 17:30:26 1617

原创 ImportError: No module named 'django.core.urlresolvers'

Django 2.0 把原来的 django.core.urlresolvers 包改为了 django.urls包,所以需要把原来的from django.core.urlresolvers import reverse 改为 from django.urls import reverse

2018-08-05 13:24:51 2465 2

空空如也

空空如也

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

TA关注的人

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