This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def V199(): | |
seq=(1,2,3,4,5,6,7,8,9) | |
for i in seq: | |
row='' | |
for j in xrange(i): | |
row=row+'%s*%s=%s\t'%(i,j+1,i*(j+1)) | |
print row | |
if __name__=='__main__': | |
V199() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
url = "https://www.douban.com/accounts/login" | |
params = | |
{ | |
"form_email":"***", | |
"form_password":"***", | |
"source":"index_nav" | |
} | |
with requests.Session() as c: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// clear stringbuffer | |
/* | |
** first method | |
*/ | |
StringBuffer sb = new StringBuffer("HelloWorld"); | |
// after many iterations and manipulations | |
sb.setLength(0); | |
/* | |
** second method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void copyFileUsingJava7Files(File source, File dest) | |
throws IOException { | |
Files.copy(source.toPath(), dest.toPath()); | |
} | |
private static void copyFileUsingFileStreams(File source, File dest) | |
throws IOException { | |
InputStream input = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
for gif in glob.glob('*.gif'): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import datetime | |
print "Time in seconds since the epoch: %s" %time.time() | |
print "Current date and time: " , datetime.datetime.now() | |
print "Or like this: " ,datetime.datetime.now().strftime("%y-%m-%d-%H-%M") | |
print "Current year: ", datetime.date.today().strftime("%Y") | |
print "Month of year: ", datetime.date.today().strftime("%B") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Method 1 | |
*/ | |
import org.apache.commons.io.FileUtils; | |
File f = new File("/dir"); | |
FileUtils.cleanDirectory(f); | |
/* | |
Method 2 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A=[1,2,3,4,5] | |
def K(): | |
while 1 in A: | |
print 'begin' | |
yield A[0] | |
print A.pop() | |
print 'end' | |
for i in K(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# @Author: youth | |
# @Date: 2015-04-11 09:20:01 | |
# @Last Modified time: 2015-04-11 10:14:58 | |
''' | |
该代码用于遥感影像的批量裁剪,其中运用到了多进程的处理模式 | |
''' | |
import os | |
import glob |
OlderNewer