码迷,mamicode.com
首页 >  
搜索关键字:python function    ( 188437个结果)
GLUT的一个简洁OO封装
Member function 如何作为Callback? 这里其实是两个问题。 第一个问题,member function的函数签名上有this指针,不能直接传给glut*Func作为callback。 member function不行,很自然的想到static function。 第二个问题,static function如何能够调用member function,且与之关联的对象(this指针)能够在运行时期(或者用户程序)决定? 其一,static function调用member functi...
分类:其他好文   时间:2014-06-09 23:27:43    阅读次数:313
Python - 定制pattern的string模板(template) 详解
定制pattern的string模板(template) 详解本文地址: http://blog.csdn.net/caroline_wendy/article/details/28625179 string.Template的pattern是一个正则表达式, 可以通过覆盖pattern属性, 定义新的正则表达式.如: 使用新的定界符"{{", 把{{var}}作为变量语法.代码:# -*- coding: utf-8 -*- ''' Creat...
分类:编程语言   时间:2014-06-08 18:00:47    阅读次数:308
Numpy 入门教程(1)
翻译自官方文档Tentative NumPy Tutorial,有删节。 Numpy 入门教程 NumPy 提供了对多维数组的支持,与Python原生支持的List类型不同,数组的所有元素必须同样的类型。数组的维度被称为axes,维数称为 rank。  Numpy的数组类型为 ndarray, ndarray 的重要属性包括:  ndarray.ndim:数组的维数,也称为rank...
分类:其他好文   时间:2014-06-08 15:15:05    阅读次数:431
检查输入的用户名是否符合规定
代码清单: <?php /** * 检测输入中是否含有错误字符 * @author ruxing.li * @param char $string 要检查的字符串名称 * @return boolean */ function is_badword($string) { $badwords = array("\\",'&',' ',"'",'"','/','*',',',''...
分类:其他好文   时间:2014-06-08 14:49:48    阅读次数:288
判断字符串是否为 utf-8 编码
代码清单: <?php /** * 判断字符串是否为utf8编码,英文和半角字符返回ture * @author ruxing.li * @param $string * @return bool */ function is_utf8($string) { return preg_match('%^(?: [\x09\x0A\x0D\x...
分类:其他好文   时间:2014-06-08 10:47:58    阅读次数:267
格式化文本域内容
本函数对 form 表单提交过来的 textarea 文本域的内容进行处理。 代码清单: <?php /** * 格式化文本域内容 * @author ruxing.li * @param $string 文本域内容 * @return string */ function formatTextarea($string) { $string = nl2br ( str_re...
分类:其他好文   时间:2014-06-08 10:36:42    阅读次数:184
Python - 定制语法的string模板(template) 详解
定制语法的string模板(template) 详解本文地址: http://blog.csdn.net/caroline_wendy/article/details/28614491 string模板(template)参考: http://blog.csdn.net/caroline_wendy/article/details/27054263string.Template()内添加替换的字符, 使用"$"符号, 或 在字符串内, 使用"${}...
分类:编程语言   时间:2014-06-08 09:21:01    阅读次数:360
在SAE上使用Ueditor的图片上传功能
SAE上是没有目录读写权限的,所以要在SAE使用Ueditor的图片上传功能需要借助SAE的Storage服务。   一、开通Storage服务   在SAE控制台开通Storage服务,并新增一个domain。         二、修改Ueditor代码   Ueditor处理上传文件的方法在DjangoUeditor/jviews.py中,上传图片的请求是由下面...
分类:其他好文   时间:2014-06-08 08:53:44    阅读次数:285
python实现表单中插入表情符号
效果: 点表情图,在表单中表示为[左晃晃]。 见过一个使用jquery来模拟新浪微博的表情插入。 使用Python2.7和Django1.6来实现。 看书好长时间,但是自己来写,发现真的没记住。 方法描述: 1、浏览器页面,使用js脚本把表情符号添加到Textarea; 2、Views里面使用正则把记录里的[]内容替换为图片,渲染到浏览器。...
分类:编程语言   时间:2014-06-08 04:06:26    阅读次数:461
LeetCode——Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, whe...
分类:其他好文   时间:2014-06-08 02:12:04    阅读次数:216
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!