代码改变世界

python regularexpress

2017-11-09 18:07 by woodzcl, 282 阅读, 0 推荐, 收藏, 编辑
摘要:这个正则表达式,我还真没有接触过,在python首次学习 //test.py 1 import re 2 3 print (re.match('www', 'www.myweb.com').span()) 4 print (re.match('com', 'www.myweb.com')) 5 6 阅读全文

python class 2

2017-11-09 16:52 by woodzcl, 276 阅读, 0 推荐, 收藏, 编辑
摘要://test.py 1 class Employee: 2 'all employee' 3 empCount = 0 4 def __init__(self, name, salary): 5 self.name = name 6 self.salary = salary 7 Employee.e 阅读全文

python class 1

2017-11-09 12:27 by woodzcl, 220 阅读, 0 推荐, 收藏, 编辑
摘要://test.py class Employee: 'all employee' empCount = 0 def __init__(self, name, salary): self.name = name self.salary = salary Employee.empCount += 1 d 阅读全文

python raise

2017-11-08 16:00 by woodzcl, 159 阅读, 0 推荐, 收藏, 编辑
摘要://test.py class myNet(RuntimeError): def __init__(self,arg): self.args = arg def mye(level): if level<1: raise Exception('123', level) try:# mye(0) ra 阅读全文

python file

2017-11-08 11:30 by woodzcl, 164 阅读, 0 推荐, 收藏, 编辑
摘要://test.py fo = open('f.txt', 'wb')print 'name',fo.nameprint 'closed',fo.closedprint 'mode',fo.modeprint 'softspace',fo.softspacefo.write('123\n')fo.wr 阅读全文

python package

2017-11-07 17:00 by woodzcl, 218 阅读, 0 推荐, 收藏, 编辑
摘要:简要说一下,一个python模块就是一个python文件;一个包就是存放python模块的目录结构,并且包下边必须要有一个可以为空的__init__.py模块 //test.py from mypackage.op1 import op1from mypackage.op2 import op2op 阅读全文

python date time

2017-11-06 17:15 by woodzcl, 233 阅读, 0 推荐, 收藏, 编辑
摘要://test.py import time ticks = time.time()print tickslocaltime = time.localtime(time.time())print localtimeprint time.asctime(localtime) print time.str 阅读全文

python dictionary

2017-11-06 15:30 by woodzcl, 317 阅读, 0 推荐, 收藏, 编辑
摘要://test.py dict = {1:1, 2:2, 3:3}print dictdel dict[2]print dictdict.clear()print dictdel dictprint dict dict1 = {1:1, 1:2}print dict1 dict3 = {(1, 2, 阅读全文

python list seq

2017-11-06 11:33 by woodzcl, 1069 阅读, 0 推荐, 收藏, 编辑
摘要://test.py list1 = [1, 2, 3]list2 = [4, 5, 6] print cmp(list1, list2)print len(list1), len(list2)print max(list1), max(list2)print min(list1), min(list 阅读全文

python string method

2017-11-03 17:47 by woodzcl, 411 阅读, 0 推荐, 收藏, 编辑
摘要:嗯,学习其它语言没这样全练过,嘻嘻 //test.py 1 # -*- coding: UTF-8 -*- 2 3 str = "i am worker" 4 print str.capitalize() 5 print str.center(20) 6 print str.count(' ') 7 阅读全文
上一页 1 2 3 4 5 6 7 8 9 ··· 11 下一页