leetcode14 14、Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings.class Solution(object): def longestCommonPrefix(self, strs): """ :ty
leetcode 165 165 easy Compare Version Numbers *Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assume that the ve
leetcode7 7 easy****Reverse Integer *Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321**class Solution(object): def reverse(self, x): """ :type x
leetcode58 58 easy Length of Last Word *Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string. If the last word does not exist, ret
leetcode263 263 easy ugly number *Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 1
leetcode350 350、easy Intersection of Two Arrays II Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note: Each element in the
leetcode349 349 easy Intersection of Two Arrays *Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element in the
leetcode27 Remove Element*Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in place with constant
leetcode283 Move Zeroes *Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after c
leetcode345 easy,345 *Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s = “hello”, return “holle”. Example 2: Given s = “leetcode”, return “leotcede”.*
leetcode344 easy:344、Reverse String Write a function that takes a string as input and returns the string reversed. 我自己是这样写的:class Solution(object): def reverseString(self, s): """ :type s: st
排序算法的学习 最好的情况下 时间复杂度是n 最会的情况下 时间复杂度是n^2 def Bubble(list): for i in range(len(list))[::-1]: for j in range(i): if list[j]>list[j+1]: list[j],list[j+1] = list[j+1],li
python challenge心得 0.pow(2,38) 或者2**381.def f(str): l=[] for x in str: if 'a'<=x<='z' or 'A'<=x<='Z': x=chr((ord(x)+2-ord('a'))%26+ord('a')) l.append(x) return ''.join(l)s="g fmnc
django开发的投票系统 不用通用视图的时候: urls.py:from django.conf.urls import urlfrom . import viewsurlpatterns = [ url(r'^$',views.index,name='index'), url(r'^(?P<question_id>[0-9]+)/$',views.detail,name='detail'), u
django的模版标签和过滤器 python manage.py shellfrom django import templateif标签的使用t = template.Template(‘{%if a%}A is true{%else%}A is False{%endif%}')t.render(template.Context({‘a’:True}))for标签的使用t = template.Template('{%for
django的模版 1、使用template context 然后使用render来渲染 2、新建一个文件夹 templates,用来存放模版 在settings中加入这样一句,告诉应用模版在什么位置TEMPLATE_DIRS = os.path.join(os.path.dirname(__file__),'templates')2.html<html><body>Hello World!hhhhhhh
Django开发 hello world 首先建立项目 在终端中输入如下命令:django-admin.py startproject mysitecd mysitedjango-admin.py startapp myapp用sublime打开 在settings中加入myapp 在views中from django.shortcuts import renderfrom django.http import HttpRespon
模型开发与数据库交互--数据库处理 models.pyfrom django.db import modelsclass Mysite(models.Model): title = models.CharField(max_length = 100) url = models.URLField() author = models.CharField(max_length = 100) num = mo
django的下载安装以及第一个项目的创建 django的下载安装以及第一个项目的创建 1、django可以通过两种方式进行安装: 【1】在django的官网上下载,然后解压 ,进入解压的目录,命令 行:python setup.py install 【2】通过pip install django==1.9.4进行安装 安装之后要配置环境变量 将D:\Python27\Lib\site-packages\django
MySQLdb的安装以及python连接数据库(win,Mac) MySQLdb的安装以及python与数据库的连接1, http://www.codegood.com/downloads在这里下载相对应的mysqlbd版本 双击安装 在命令行中输入python import MySQLdb 如果没有任何提示 则说明安装正确 注意:MySQLbd的大小写 否则还是提示不正确 2.安装好后 可以建立python与数据库的连接了import MySQLdbco
django的下载安装以及第一个项目的创建 django的下载安装以及第一个项目的创建1、django可以通过两种方式进行安装:【1】在django的官网上下载,然后解压 ,进入解压的目录,命令行:python setup.py install 【2】通过pip install django==1.9.4进行安装 安装之后要配置环境变量 将D:\Python27\Lib\site-packages\django加入path中
JSP指令元素:page指令 include指令 tag lib指令。 JSP指令元素:page指令 include指令 tag lib指令。一、指令元素(directive elements):控制所生成的servlet结构。 JSP指令用于“转换阶段”提供整个JSP页面的相关信息,影响由JSP页面生成的Servlet的整体结构。 指令不会产生任何的输出到当前的输出流中。 1,指令元素语法: 说明: 之间不能有
struts2 基本概念struts2(主要负责表现层)并不是一个陌生的web框架,它是以webwork的设计思想为核心,吸收struts1的优点,可以说struts2是struts1和webwork的结合产物。struts2大致可以分为3个部分:核心控制器FilterDispatcher,业务控制器Action和用户实现的企业业务逻辑组建。核心控制器FilterDispacher是struts2框架的基础,包含了
关于网站分层设计的学习 简介web设计遵循简单的原则,通常分为三个层次进行开发,分别为表现层,业务逻辑层,和持久层。下面分别介绍这三个名词。表现层表现层就是我们平时所看到的页面,主要采用的是struts构架,struts构架实现了MVC模型,使得显示(view),控制(controler),和模型(model)部分相互分离,提高了代码的可重复性。业务逻辑层通常也成为中间层,包含服务层和dao层,对整个网站的业务逻辑进行处理
tomcat启动失败,原因端口占用 启动tomcat发现端口被占用0x00 背景在点击了tomcat/bin/startup.bat,启动tomcat后,在浏览器访问本地tomcat,发现打不开,于是我到tomcat的logs目录下查看catalina.log文件,查看到以下错误: 百度之后,发现错误为端口被占用,使用的是win7系统,解决办法如下: 0x01 解决方法一、检查正在使用的端口首先打开cmd,打开的方法很
web研发模式演变史 一、简单明快的早期时代 可称之为 Web 1.0 时代,非常适合创业型小项目,不分前后端,经常 3-5 人搞定所有开发。页面由 JSP、PHP 等工程师在服务端生成,浏览器负责展现。基本上是服务端给什么浏览器就展现什么,展现的控制在 Web Server 层。这种模式的好处是:简单明快,本地起一个 Tomcat 或 Apache 就能开发,调试什么的都还好,只要业务不太复杂。 然而业务总会变复
使用命令行对java程序的编译运行和打包 0x00 背景我们平时使用了在有IDE的环境下编写代码,编译的工作会由IDE自动完成,这样方便了我们工作,但是却使我们忽略了代码是如何执行的本质,或者当电脑上只有jre环境,没有开发环境,就需要在cmd环境下进行java程序的编译和运行,本文详细介绍了如何在cmd环境下使用命令行执行java程序。0x01 使用javac和java编译和执行java程序1、Java源程序经过编译器编译后编成字节码,