- 军军小站|张军博客
搜索到与相关的文章
Python

leetcode 53. Maximum Subarray 解法 python

一.问题描述Givenanintegerarraynums,findthecontiguoussubarray(containingatleastonenumber)whichhasthelargestsumandreturnitssum.Example:Input:[-2,1,-3,4,-1,2,1,-5,4],Output:6Explanation:[4,-1,2,1]hasthelargestsum=6.Followup:Ifyouhavefigur

系统 2019-09-27 17:53:31 1801

Python

python2.7.13和matplotlib2.2.0出错

问题如下ExceptioninTkintercallbackTraceback(mostrecentcalllast):File"C:\Python27\lib\lib-tk\Tkinter.py",line1542,in__call__returnself.func(*args)File"C:\Users\11782\AppData\Roaming\Python\Python27\site-packages\matplotlib\backends\bac

系统 2019-09-27 17:53:25 1801

Python

Python实现某论坛自动签到功能

1.[文件]DakeleSign.py~4KB#!/usr/bin/envpython#-*-coding:utf-8-*-__author__='poppy''''dakelebbssigin'''importsysimporturllib2importurllibimportrequestsimportcookielibimportjsonfrompyqueryimportPyQueryaspqimportlogginglogging.basicCon

系统 2019-09-27 17:53:08 1801

Python

python入门之语句(if语句、while语句、for语句)

python入门之语句,包括if语句、while语句、for语句,供python初学者参考。//if语句例子name='peirong';ifname=='peirong':print'thisispeirong';elifname=='maojun':print'thisismaojun';else:print'others';//while语句i=0;a=range(10);whilei

系统 2019-09-27 17:52:55 1801

Python

Python中正则表达式的巧妙使用一文包你必掌握正则

前言正则表达式就是从字符串中发现规律,并通过“抽象”的符号表达出来。打个比方,对于2,5,10,17,26,37这样的数字序列,如何计算第7个值,肯定要先找该序列的规律,然后用n2+1这个表达式来描述其规律,进而得到第7个值为50。对于需要匹配的字符串来说,同样把发现规律作为第一步,本文主要使用正则表达式完成字符串的查询匹配、替换匹配和分割匹配。常用的正则符号在进入字符串的匹配之前,先来了解一下都有哪些常用的正则符号,见下表所示:如果读者能够比较熟练地掌握

系统 2019-09-27 17:52:54 1801

Python

Python 学习 第17篇:json

Python中的json对象实际是一个字典结构,用于存储和交换信息,导入json模块:importjson1,把字符串转换为jsonjson的load()方法用于把josn格式的字符串转换为json对象,这实际上是一个字典结构:json_string='{"name":"John","age":30,"city":"NewYork"}'#parsestringtojsonjson_obj=json.loads(json_string)2,把字典转换为jso

系统 2019-09-27 17:52:33 1801

Python

python3中eval函数用法使用简介

python中eval函数的用法十分的灵活,这里主要介绍一下它的原理和一些使用的场合。下面是从python的官方文档中的解释:Theargumentsareastringandoptionalglobalsandlocals.Ifprovided,globalsmustbeadictionary.Ifprovided,localscanbeanymappingobject.Theexpressionargumentisparsedandevaluateda

系统 2019-09-27 17:52:12 1801

Python

Python字符串对象实现原理详解

在Python世界中将对象分为两种:一种是定长对象,比如整数,整数对象定义的时候就能确定它所占用的内存空间大小,另一种是变长对象,在对象定义时并不知道是多少,比如:str,list,set,dict等。>>>importsys>>>sys.getsizeof(1000)28>>>sys.getsizeof(2000)28>>>sys.getsizeof("python")55>>>sys.getsizeof("java")53如上,整数对象所占用的内存都是

系统 2019-09-27 17:52:10 1801

Python

[python整理]@staticmethod和@classmethod的作用

前言知识在于细节,整理很重要。在python中,有3类方法:1)静态方法(staticmethod)2)类方法(classmethod)3)实例方法其中静态方法和类方法是不需要进行实例就可以直接调用,语法格式:类名.方法名具体举个例子说明deffunc(x):print("hello,我是常用方法")classFun:deffunc1(self,x):print("hello,我是类中方法",x,self)@classmethoddeffunc2(cls,

系统 2019-09-27 17:51:55 1801

Python

插入、冒泡、快排、选择排序算法python2代码实现

目录一、插入排序二、冒泡排序三、快排(递归)四、选择排序生成一个长度为10的范围在0~20的随机数组importrandomtemp_list=[]whileTrue:num=random.randint(0,20)ifnumnotintemp_list:temp_list.append(num)iflen(temp_list)==10:breakprinttemp_list一、插入排序definsert(list):length=len(list)for

系统 2019-09-27 17:51:37 1801