1。import math ,无分号结尾,函数定义:x= 1def change(): x= 10; print x;print x显示1;x= 1def change(): globle x ; x= 10; print x;print x显示10;对象定义class MyClass: ...
分类:
编程语言 时间:
2015-09-03 10:21:17
阅读次数:
193
直接贴上代码import threading def sayhello(): print "hello world" global t #Notice: use global variable! t = threading.Timer(5...
分类:
编程语言 时间:
2015-09-02 23:20:57
阅读次数:
220
线上有需求,就是根据一个文件列表,去复制到相应的目录,而且要保持目录结构。贴代码#!/usr/bin/envpython
##coding=utf-8
print"""
从存储服务器导出到临时目录
"""
importos
importshutil
fromos.pathimportexists,abspath,dirname,isfile
des_dir="/data"
f=open(‘file.li..
分类:
编程语言 时间:
2015-09-02 20:48:30
阅读次数:
265
awk的妙用:提取数字600,注意+号的特殊作用。echo"fuck600ms"|awk‘{print+$NF}‘结果:过滤了其他字符,只留下数字600在commad模式下使用if,for#测试ifa=200if[$a==200];thenecho"ais$a";fi##测试for循环forxin"cat""dog""pig";doecho$x;done##排除bzezt的文件,其他的输出大校..
分类:
系统相关 时间:
2015-09-02 19:07:24
阅读次数:
215
考虑以下情况: (1).根据程序输出可以很好地帮助程序员调试程序。在编写小型程序时,可以在程序中不断增加 System.out.print()语句来查看程序运行状态;在大型系统中,显然这一做法非常不对,可以考虑将调试信息通过日志处理工具,输出到一个文本文件中,然后查看文件内容。 (2).在系统开.....
分类:
编程语言 时间:
2015-09-02 18:53:35
阅读次数:
197
// MyProtocol.h#import @protocol MyProtocol @optional- (void)print:(int)value;@required- (int)printValue:(int)value1 andValue:(int)value2;@end// MyTes...
分类:
其他好文 时间:
2015-09-02 18:45:01
阅读次数:
114
#coding=utf-8importurllib2importreimporttimedeftimestamp():returnstr(time.strftime("%Y-%m-%d%H:%M:%S",time.localtime()))print'starttime:'+timestamp()f...
分类:
Web程序 时间:
2015-09-02 18:44:53
阅读次数:
144
head-n, --lines=[-]K print the first K lines instead of the first 10; with the leading ‘-’, print all but the last K lines of each filetai...
分类:
其他好文 时间:
2015-09-02 17:21:34
阅读次数:
176
<?php
$my_array?=?array("a"?=>?"Dog",?"b"?=>?"Cat",?"c"?=>?"Horse");
//=>区分键值
sort($my_array);//对数组进行排序
print_r($my_array);
?> <?php
$my_array?=?array(?"Dog",??"Cat","Ho...
分类:
其他好文 时间:
2015-09-02 14:52:25
阅读次数:
145
>>>?a
[1,?2,?3]
>>>?b
[1,?2,?3,?4] 差集 >>>?list(set(b).difference(set(a)))
[4] >>>?print?list(set(a)?^?set(b))
[4] >>>?print?list(set(b)?-?set(a))
[4]???????????????...
分类:
编程语言 时间:
2015-09-02 12:00:03
阅读次数:
205