7.5 字符串模式匹配
re模块为高级字符串成处理提供了正则表达式匹配。 对于复杂的匹配和处理,正则表达式能够提供简明优化的方法:
>>> import re
>>> re.findall(r’\bf[a-z]*’, ’which foot or hand fell fastest’)
[’foot’, ’fell’, ’fastest’]
>>> re.sub(r’(\b[a-z]+)...
分类:
编程语言 时间:
2014-05-14 01:04:22
阅读次数:
490
之前在用电池医生的时候, 发现它有这样一个功能:当应用进入后台的时候, 会显示另外一张图片覆盖App Switcher显示的界面。效果如下:变成---->而这样的一个功能, 对于保护用户隐私还是挺有用的。这就涉及到了Background Fetch的使用。当然, Background Fetch有更多,更有用的功能, 详见-->iOS 7学习:多任务处理之Background Fetch下面就介绍...
分类:
移动开发 时间:
2014-05-13 23:44:37
阅读次数:
535
python中的单元测试可以使用doctest,unittest完成
1.doctest的使用
(1)写入程序如下(cubetest.py):
#!/usr/bin/python
def cube(x):
"""
cube a number and return the result
>>> cube(2)
8
>>> cube(3)
27
>>> cube(4)
64...
分类:
编程语言 时间:
2014-05-13 23:33:19
阅读次数:
491
群聊的前台主要代码:
{%block content%}
测试版本,每天凌晨4:00清水,enjoy it~~:-)-->
{%for i in content[19*int(num)-19:19*int(num)]%}
【{{i[1]}}】 ({{i[3]}}) : {{i[2]}}
{%end%}
{%for i in range(1,pages+1)%}
{{i}}
{%...
分类:
其他好文 时间:
2014-05-13 23:14:45
阅读次数:
388
为了让编译器更好地优化循环,应该尽量让循环中减少判断,方法之一是将判断语句整合进表达式。还是这个例子:
for (int i = 0; i < 1000*10; i++)
{
sum += data[i/1000][i%10];
}
假如我们需要加一个判断,只有非负整数才需要作求和运算:
for (int i = 0; i
{
if (data[i/10...
分类:
编程语言 时间:
2014-05-13 23:01:28
阅读次数:
324
手动模拟。。
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define N 10100
#define inf 1000000010
mapx,y;
struct X{
int x,y;
bool operator<(const X&a)const{...
分类:
其他好文 时间:
2014-05-13 07:29:10
阅读次数:
294
下面是HTML文件用于上传3个文件
ACTION="Upload.asp">
Image
Text
Source Code
Archive
上传程序(Upload.asp):
Set Upload = Server.CreateObject("Persits.Upload.1")
...
分类:
其他好文 时间:
2014-05-13 00:21:11
阅读次数:
270
楼主让这个问题郁闷了一晚上。。。。。在logcat里明明显示adapter的getview方法里的list大于一条数据 ,但posotion却一直是0.。。。。运行后也只显示list[0]里面的数据。。。。最后的最后原来错误出在布局文件上
我以前的是这样的;
<ScrollView
android:layout_width="fill_parent"
...
分类:
移动开发 时间:
2014-05-12 23:36:45
阅读次数:
386
暴力出奇迹。。
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define ll __int64
#define N 42
ll n,m,ans;
ll Gcd(ll x,ll y){
if(x>y)swap(x,y);
while(x){
y%=...
分类:
其他好文 时间:
2014-05-12 23:11:06
阅读次数:
445
7.1 操作系统接口
Os模块提供主要许多与操作系统交互的函数。
>>> import os
>>> os.getcwd() # Return the current working directory
’C:\\Python31’
>>> os.chdir(’/server/accesslogs’) # Change current working directory
>>> ...
分类:
编程语言 时间:
2014-05-12 23:08:03
阅读次数:
356