foo=‘abc‘
foriinrange(len(foo)):
print"%d,%s"%(i,foo[i])
print[x**2forxinrange(5)ifnotx%2]
try:
f=open(‘e:\XIN_370_logic.tx‘,‘r‘)
foreachlineinf:
printeachline
f.close()
exceptIOError,e:
printe
deffunc1(x):
returnx+x
x=[iforiinrange(4)]
printfunc1(x)
deffun..
分类:
编程语言 时间:
2016-06-23 19:01:28
阅读次数:
209
#importmath
#printcoerce(1L,134)
#"""数据类型转换"""
#printcoerce(0.4,123)
#printcoerce(0j,234)
#printdivmod(125,5)
#"""除法运算"""
#printdivmod(4,3)
#printpow(2,4)
#"""密"""
#printround(3)
#printround(3.666666,3)
#printround(3.045,1)
#printround(3.7777)
#"..
分类:
编程语言 时间:
2016-06-23 19:02:23
阅读次数:
298
str1=‘abced‘
foriinrange(-1,-len(str1),-1)+[None]:
printstr1[:i]
s,t=‘abc‘,‘def‘
printzip(s,t)
fori,tinenumerate(str1):
printi,t
printisinstance(‘foo‘,str)
importstring
defcheckid():
alphas=string.letters+‘_‘
nums=string.digits
check=raw_input(‘inputid..
分类:
编程语言 时间:
2016-06-23 19:04:11
阅读次数:
391
deffunc1():
dict1={}
dict2={‘name‘:‘earth‘,‘port‘:80}
returndict1,dict2
deffunc2():
returndict(([‘x‘,1],[‘y‘,2]))
deffunc3():
adict={}.fromkeys([‘x‘,‘y‘],23)
returnadict
deffunc4():
alist={‘name‘:‘earth‘,‘port‘:80}
forkeysinalist.keys():
print"%s%s"%(key..
分类:
编程语言 时间:
2016-06-23 19:01:39
阅读次数:
236
deffunc1():
alist=[‘Cathy‘,‘Terry‘,‘Joe‘,‘Health‘,‘Lucy‘]
foriinrange(-1,-len(alist)-1,-1):
printi,alist[i]
deffunc2():
alist=[‘Cathy‘,‘Terry‘,‘Joe‘,‘Health‘,‘Lucy‘]
fori,nameinenumerate(alist):
print‘%d%s‘%(i,name)
importrandom
deffunc3():
alist=[‘Cathy‘..
分类:
编程语言 时间:
2016-06-23 19:01:02
阅读次数:
234
classC(object):
def__call__(self,*args,**kwargs):
print"I‘mcallable!calledwithargs:\n",args
c=C()
c(‘a‘,1)
single_code=compile("print‘hello,world!‘",‘‘,‘single‘)
exec(single_code)
eval_code=compile(‘100*3‘,‘‘,‘eval‘)
printeval(eval_code)
#exec_code=compile..
分类:
编程语言 时间:
2016-06-23 19:02:36
阅读次数:
219
importos
ls=os.linesep
deffunc1():
filename=raw_input(‘enterfilename:‘)
f=open(filename,‘w‘)
whileTrue:
alline=raw_input("enteraline(‘.‘toquit):")
ifalline!=‘.‘:
f.write("%s%s"%(alline,ls))
else:
break
f.close()
deffunc2():
f=open(‘e:\\thefile.txt‘,‘w+‘)
p..
分类:
编程语言 时间:
2016-06-23 19:02:33
阅读次数:
279
deffunc1():
try:
returnfloat(‘abc‘)
exceptValueError,e:
printe
deffunc2():
try:
astr=‘abc‘
float(astr)
exceptValueError:
astr=None
returnastr
deffunc3():
try:
astr=‘abc‘
float(astr)
exceptValueError:
astr=‘countnotconvertnon-numbertofloat‘
returnastr
defsa..
分类:
编程语言 时间:
2016-06-23 19:02:24
阅读次数:
202
deffunc1():
print‘helloworld‘
res=func1()
printtype(res)
deffunc2():
return[‘xyz‘,10000,-98]
atuple=func2()
x,y,z=func2()
printx,y,z
deffunc3():
return‘xyz‘,1000,-98
x,y,z=func3()
printx,y,z
deffunc4():
return[‘xyz‘,1000,-98,‘xxx‘]
x,y,z,d=func4()
alist=x,y..
分类:
编程语言 时间:
2016-06-23 19:02:35
阅读次数:
256
classAddrBookEntry(object):
‘addressbookentryclass‘
def__init__(self,nm,ph):
self.name=nm
self.phone=ph
print‘createdinstancefor:‘,self.name
defupdatephone(self,newph):
self.phone=newph
print‘updatephonefor:‘,self.name
defupdatename(self,newname):
self.name..
分类:
编程语言 时间:
2016-06-23 18:59:59
阅读次数:
203
Java性能分析是一门艺术和科学;科学指的是性能分析一般都包括大量的数字、测量和分析。绝大多数的性能工程师都有科学背景,运用科学的严谨是获取最大性能的重要组成部分。艺术部分指的是什么呢?性能调优是部分科学部分艺术的观点是很早就有的,但是关于性能的主题很少会给定特定的知识,这就是艺术的部分了,它和我们平常接受到的培训是不一样的,培训是确定了的。还有部分原因是对于某些人来说,性能调优是建立在深入的知识...
分类:
编程语言 时间:
2016-06-23 18:55:25
阅读次数:
230
hashlib常用加密方法:md5(), sha1(), sha224(), sha356(), sha384(), sha512()等 结果显示方法: digest(): 返回二进制字符串 hexdigest(): 返回十六进制字符串 简单的md5加密示例: ...
分类:
编程语言 时间:
2016-06-23 18:53:24
阅读次数:
159
在上周去面试的时候,面试官问了我一个关于线程池的问题,当时没有答上来。所以,回来了之后决定重新学习一下多线程。 这也是本人第一次写博客,之前一直想写,但是,一直没有搞清楚博客园的博客系统是怎么玩的。这次,到网上看到了一些关于博客园的小技巧,正好最近在学习多线程,拿来练练手。 1.创建线程 2.线程安 ...
分类:
编程语言 时间:
2016-06-23 18:53:25
阅读次数:
168
在写Java程序时,通常我们管只有一个main函数(而没有别的Thread或Runnable的程序)叫单线程程序。但是我们写的这个所谓的单线程程序只是JVM这个程序中的一个线程,JVM本身是一个多线程的程序,至少得有一个垃圾收集器线程吧。 刚装了一个NetBeans6.0,里面带了一个分析器包,于是 ...
分类:
编程语言 时间:
2016-06-23 18:51:35
阅读次数:
147
...
分类:
编程语言 时间:
2016-06-23 18:49:39
阅读次数:
162
第一章 预备知识C++在C语言的基础上添加了对"面向对象编程"的支持和对"泛型编程"的支持。类 —— 面向对象模板 —— 泛型编程1.1 C++简介1.2 C++简史1.3 可移植性和标准1.4 程序创建的技巧http://www.cnblogs.com/moonlightpoet/p/561166 ...
分类:
编程语言 时间:
2016-06-23 18:48:40
阅读次数:
133
转载自http://blog.jobbole.com/44015/ 在C++11新标准中,语言本身和标准库都增加了很多新内容,本文只涉及了一些皮毛。不过我相信这些新特性当中有一些,应该成为所有C++开发者的常规装备。你也许看到过许多类似介绍各种C++11特性的文章。下面是我总结的,C++开发者都需要 ...
分类:
编程语言 时间:
2016-06-23 18:46:21
阅读次数:
206