python里的数组何等重要,不用多言,看完下面的代码,一定受益匪浅#!/usr/bin/env python## [代码名字: Lists 101]# [代码分类: Python Core]# [代码描述: Basic and not so basic list operations]# [代码作者: Bruno Girin <……继续阅读 » 10年前 (2017-04-10) 2021浏览 2122个赞
学习在python中如何使用参数一定要看下面的代码#!/usr/bin/env python## [代码名字: Arguments]# [代码分类: Python Core]# [代码描述: GNU style arguments]# [代码作者: Jurjen Stellingwerff <jurjen@stwerff.xs4a……继续阅读 » 10年前 (2017-04-10) 2547浏览 1461个赞
python读取目录下的内容,包含子目录和文件夹#!/usr/bin/env python## [代码名字: List Directories Content]# [代码分类: os]# [代码描述: List the content of the home directory]# [代码作者: Andy Breiner <bre……继续阅读 » 10年前 (2017-04-10) 1858浏览 839个赞
python生成一个可以被遍历的函数,听起来很绕口,到底什么意思,就是可以把一个函数当成列表一样可以进行遍历,下面的代码中,函数每次运行生成的值都不一样,如果不设置终止次数,则会永远的遍历下去,看了这段代码,真实感到了python的强大def fibonacci(start=(0, 1), stop=10): """……继续阅读 » 10年前 (2017-04-10) 2011浏览 2020个赞
python中数组使用非常频繁,此代码方便的遍历数组items = [ 1, 2, 3, 4, 5 ]for i in items: print i ……继续阅读 » 10年前 (2017-04-10) 3108浏览 2136个赞
Filter, Map & Reduce of lists# [代码名字: Filter, Map & Reduce of lists]# [代码分类: Python Core]# [代码描述: Simple examples to show common features in everyday work with lists]……继续阅读 » 10年前 (2017-04-10) 3215浏览 305个赞
最近在通过python开发微信公众号的授权,发现python中的urllib.quote生成的uri和微信要求的不一样,主要是python没有将 / 转码,而微信是要求 / 也转码的,解决办法如下import urlliburllib.quote('http://www.75271.com',safe='')……继续阅读 » 10年前 (2017-04-01) 2092浏览 1352个赞
PHP创建标签云设计代码function getCloud( $data = array(), $minFontSize = 12, $maxFontSize = 30 ){$minimumCount = min( array_values( $data ) );$maximumCount = max( array_values( $data ……继续阅读 » 10年前 (2017-04-01) 2566浏览 2766个赞
PHP解压缩 Zip 文件/********************** *@file - path to zip file *@destination - destination directory for unzipped files */ function unzip_file($file, $destination){ // c……继续阅读 » 10年前 (2017-04-01) 3775浏览 2130个赞
关键词高亮function highlight($sString, $aWords) { if (!is_array ($aWords) || empty ($aWords) || !is_string ($sString)) { return false; } $sWords = implode ('|', $a……继续阅读 » 10年前 (2017-04-01) 2429浏览 2766个赞
PHP 远程文件类(支持断点续传) <?php/** * 下载远程文件类支持断点续传 */class HttpDownload { private $m_url = ""; private $m_urlpath = ""; private $m_scheme = "htt……继续阅读 » 10年前 (2017-04-01) 1857浏览 1400个赞
JAVA如何验证指定QQ用戶状态是否在线import java.io.IOException;import java.net.HttpURLConnection;import java.net.URL;public class Qq{ public static String qUrl = "QQ号码";……继续阅读 » 10年前 (2017-04-01) 2700浏览 1397个赞
java语言将大数组拆分成小数组示例//定义一个长度为X的数组 String[] all = new String[10]; for (int i = 0; i < 10; i++) { all[i]="组"+i; } //定义每个小数组的长度 int SMS_GROUP_NUMER = 3……继续阅读 » 10年前 (2017-04-01) 3631浏览 840个赞
Android下快速生成get、set、toString等方法,Java语法 有两种方式:方式一:通过快捷键Alt+Insert方式二:Code–>Generate刚开始使用Android Studio时,在创建一个javabean时,很习惯的在JavaBean类中,右键去找生成get,set等选项。但是……继续阅读 » 10年前 (2017-04-01) 2201浏览 2491个赞
python怎么样获得http状态码是不是404或者500的方法python可以通过urllib和requests两个模块来获得网页的状态嘛,一般网页如果是正常状态,状态码为200,如果出现程序上的错误状态码是500,如果未找到文件,状态码是404.第一种,通过urllib可以轻易获得网页的状态码import urllibstatus=urll……继续阅读 » 10年前 (2017-04-01) 3245浏览 1209个赞
使用Django类如何使用二进制数据输出图片的方法有时候我们的图片是通过代码生成的,比如二维码和处理过的图片,我们不需要将图片存储为文件即可直接输出文件到浏览器。from django.http import HttpResponse def my_image(request): image_data = open("pict……继续阅读 » 10年前 (2017-04-01) 2257浏览 136个赞
python-qrcode是个用来生成二维码图片的第三方模块,依赖于 PIL 模块和 qrcode 库。QRCode官网 https://pypi.python.org/pypi/qrcode/5.1简单用法import qrcode img = qrcode.make('hello, qrcode')img.save(……继续阅读 » 10年前 (2017-04-01) 2922浏览 1352个赞
python代码实现二分查找示范二分查找又称折半查找,优点是比较次数少,查找速度快,平均性能好;其缺点是要求待查表为有序表,且插入删除困难。因此,折半查找方法适用于不经常变动而查找频繁的有序列表。def BinarySearch(alist, target): low, high = 0, len(alist)-1 while low……继续阅读 » 10年前 (2017-04-01) 2468浏览 1751个赞
如何使用python的httplib发送GET和POST请求功能代码python有一个httplib的库,提供了很方便的实现方法GET和POST请求,只需要简单的组合一下就行了。python发送get请求代码:#!/usr/bin/env python#coding=utf8 import httplib httpClient = ……继续阅读 » 10年前 (2017-04-01) 2668浏览 2847个赞
mongodb中数组查询的两个简单语句的使用方法 通过$in和$all 关键词对mongodb的数组进行查询的代码,下面介绍了mongodb中的方法这条语句查询site字段中同时包含haotu.net 和 75271.com 两个元素的记录db.food.find({“site”:{“$a……继续阅读 » 10年前 (2017-04-01) 2840浏览 824个赞
UTF-8、GB2312都支持的汉字截取函数/* Utf-8、gb2312都支持的汉字截取函数 cut_str(字符串, 截取长度, 开始长度, 编码); 编码默认为 utf-8 开始长度默认为 0 */ function cut_str($string, $sublen, $start = 0, $code = ……继续阅读 » 10年前 (2017-04-01) 2441浏览 2316个赞
java 随机队列实现的完整方法import java.util.ArrayList;import java.util.Collection;import java.util.Iterator;import java.util.LinkedList;import java.util.NoSuchElementException;impo……继续阅读 » 10年前 (2017-03-31) 2084浏览 2513个赞
php通过HTTP_USER_AGENT判断用户是否是在微信客户端内打开的网页function is_weixin(){ if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) { ret……继续阅读 » 10年前 (2017-03-31) 3202浏览 391个赞
js使用try…catch捕捉错误信息代码方法var txt="";function message(){try { adddlert("Welcome guest!"); }catch(err) { txt="There was……继续阅读 » 10年前 (2017-03-31) 2942浏览 1727个赞
JavaScript中可以通过continue临时中止循环的某次动作,然后继续执行<p>Click the button to do a loop which will skip the step where i=3.</p><button>Try it</button><p……继续阅读 » 10年前 (2017-03-31) 2402浏览 763个赞
下面的代码提供了Python 最常用的日期和时间操作方法,包括日期转换,获得当前时间,获得多少天以后的日期等等,非常全面。#-*- coding: utf-8 -*-import datetime #给定日期向后N天的日期def dateadd_day(days): d1 = datetime.datetime.now() ……继续阅读 » 10年前 (2017-03-31) 2876浏览 1977个赞
php 树形结构的读取<?php // 从数组转换,操作无限分类数组. // 数组格式, array(array('cid', 'pid', 'val'), array('cid', 'pid', 'val')); class tr……继续阅读 » 10年前 (2017-03-31) 2492浏览 240个赞
java 简单实用的文件下载代码package wan.url.download;import java.io.File;import java.io.FileOutputStream;import java.io.InputStream;import java.io.OutputStream;import java.net.Htt……继续阅读 » 10年前 (2017-03-31) 3558浏览 1605个赞
下面的演示代码通过while循环语句输出数字1-6<p>75271.com,Click the button to loop through a block of as long as <em>i</em> is less than 5.</p><button>Try it……继续阅读 » 10年前 (2017-03-31) 3028浏览 2828个赞
Js通过记录cookie临时访客信息用户第一次访问网页时会提示用户输入一个昵称,然后写入cookie,当用户再次来到时会读取cookie信息,提取用户昵称,欢迎用户的到来function getCookie(c_name){var c_value = document.cookie;var c_start = c_valu……继续阅读 » 10年前 (2017-03-31) 3188浏览 2917个赞
JavaScript中我们可以定义一个通用的错误处理程序,只要页面出现JS错误就自动调用已经定义好的错误处理程序onerror=handleErr;var txt="";function handleErr(msg,url,l){txt="There was an error on th……继续阅读 » 10年前 (2017-03-31) 2308浏览 926个赞
js搜索字符串,成功后返回找到的字符串-JavaScript字符串带有一个match方法用于搜索字符串,如果找到指定的字符串则返回搜索字符串,如果未找到则返回null,match方法区分大小写var str="Hello world!";document.write(str.match("worl……继续阅读 » 10年前 (2017-03-30) 2631浏览 1799个赞
js代码输出当前时间Unix时间戳-JavaScript语言下面的代码通过Date对象的getTime()放回unix时间戳,即从1970年1月1日到当前时间的秒数<p id="demo">Click the button to display the number of milliseconds si……继续阅读 » 10年前 (2017-03-30) 2378浏览 418个赞
js将当前时间转换为标准UTC时间-JavaScript代码,北京在东八区,在北京时间基础上减掉8小时<p id="demo">Click the button to display the UTC date and time as a string.</p><button>……继续阅读 » 10年前 (2017-03-30) 1733浏览 2499个赞
C#使用TextReader从文本类型文件读取数据TextReader reader = File.OpenText(@"C:\data\file.xml"); // Read a line at a time until we reach the end of filewhile (reader.Peek( ) != ……继续阅读 » 10年前 (2017-03-30) 3546浏览 798个赞
在Linux系统里使用C语言获取所有网卡信息的方法#include #include #include #include #include int main(){ struct ifreq ifr; struct ifconf ifc; char buf[2048]; int succ……继续阅读 » 10年前 (2017-03-30) 1908浏览 836个赞
使用JavaScript语言创建数组的方法,下面的代码演示了在JS中如何创建数组并赋值,然后对数组进行循环遍历输出var i;var mycars = new Array();mycars[0] = "Saab";mycars[1] = "Volvo";mycars[2] = ……继续阅读 » 10年前 (2017-03-30) 3177浏览 767个赞
在JavaScript代码中让contact函数合并两个数组下面的代码演示了JS中如何将两个数组连接成一个数组<p id="demo">Click the button to join three arrays.</p><button>Try it</button&……继续阅读 » 10年前 (2017-03-30) 2509浏览 394个赞
怎么样用JavaScript的alert显示带换行的警告对话框JavaScript的alert对话框如果需要换行的话可以在字符串中加入\n即可<p>Click the button to demonstrate line-breaks in a popup box.</p><button>T……继续阅读 » 10年前 (2017-03-30) 2098浏览 608个赞
使用JavaScript语言获取iframe的longdesc属性<p>Your browser does not support iframes.</p><p>The URL of the long description is:document.write(document……继续阅读 » 10年前 (2017-03-30) 2173浏览 417个赞
JavaScript中可以使用confirm弹出一个确认对话框,用户可以点击ok或者cancel,JS可以接收到用户点击的按钮<p>Click the button to display a confirm box.</p><button>Try it</button>&l……继续阅读 » 10年前 (2017-03-30) 2818浏览 988个赞
C#代码实现穿过代理服务器取远程用户真实IP地址 if(Request.ServerVariables["HTTP_VIA"]!=null){ string user_IP=Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); ……继续阅读 » 10年前 (2017-03-30) 1839浏览 1539个赞
这段代码用来判断ie的版本,不同的版本调用不同的样式<!-- [if IE]>-->According to the conditional comment this is Internet Explorer<!-- [if IE 5]>-->According to the conditional ……继续阅读 » 10年前 (2017-03-30) 2850浏览 1215个赞
一个构造sql语句的类/*** @package Database Class* @author injection (mail:injection.mail@gmail.com)* @version 1.0*/@ini_set( 'display_errors',0 );class DataBas……继续阅读 » 10年前 (2017-03-30) 3298浏览 2925个赞
js提示用户输入对话框prompt使用代码演示使用JavaScript代码Click the button to demonstrate the prompt box.Try itfunction myFunction(){var x;var person=prompt(“Please enter your name”,&……继续阅读 » 10年前 (2017-03-30) 1989浏览 488个赞