上一页 1 ··· 9 10 11 12 13 14 15 下一页
摘要: ##importlogginglogging.debug('debug message')logging.info('info message')logging.warning('warning message') # WARNING:root:warning messagelogging.erro 阅读全文
posted @ 2017-12-31 21:45 Alos403 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 注意迭代器和可迭代对象不同#迭代器:1、有iter方法,2、有next方法li=[1,2,3,4,5]d=iter(li) # 等于li.__iter__()print(d) # <list_iteratorobjectat0x00000174316CC3C8>可以通过next方法取出元素。for循 阅读全文
posted @ 2017-12-31 21:24 Alos403 阅读(165) 评论(0) 推荐(0) 编辑
摘要: #里面内容没有见过,可能会比较难懂,需要找资料。我只是记录了视频中的用法,其他理解的东西,我直接理解,就没有写下来了。下面内容是视频演示过程 import hashlibm = hashlib.md5()print(m) # 只是一个加密对象m.update('aiq'.encode('utf-8' 阅读全文
posted @ 2017-12-29 01:13 Alos403 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 为了和python解释器交互,控制台执行脚本后面添加变量import sysprint(sys.argv) def post(): print('upload')def download(): print('download')if sys.argv[1] == 'post': post()elif 阅读全文
posted @ 2017-12-29 00:30 Alos403 阅读(236) 评论(0) 推荐(0) 编辑
摘要: import osprint(os.getcwd()) # 获取当前目录 F:\python_code\fullstack_s2\week4\day18os.chdir(r'C:/Users')print(os.getcwd()) #改变当前工作目录 C:\Users print(os.curdir 阅读全文
posted @ 2017-12-28 21:30 Alos403 阅读(250) 评论(0) 推荐(0) 编辑
摘要: import randomprint(random.random())print(random.randint(1,8)) #包括8 print(random.choice('aiq')) # aiq随便一个print(random.randrange(1,10)) #不包括10print(rand 阅读全文
posted @ 2017-12-28 13:34 Alos403 阅读(162) 评论(0) 推荐(0) 编辑
摘要: #有‘*’为重点import timeprint(time.time())#以秒的形式返回******time.sleep(3) ******print(time.clock()) #cpu执行的时间print(time.gmtime()) # 结构化时间,本初子午线那里的时间time.struct 阅读全文
posted @ 2017-12-27 21:59 Alos403 阅读(174) 评论(0) 推荐(0) 编辑
摘要: ##补充:列表生成器 1 #两个理解例子 2 a=[x**2 for x in range(10)] #取x,然后执行x**2,在存放到列表里面 3 print(a) #[0,1,4,9,16,25,36,49,64,81] 4 5 def f(n): 6 return n**2 7 a=[f(x) 阅读全文
posted @ 2017-12-26 23:55 Alos403 阅读(237) 评论(0) 推荐(0) 编辑
摘要: ##闭包 :内部函数,在外部调用不在他函数范围的变量 def outer(): x=10 def inner(): print(x) return inner #outer()() f=outer() f() 这里inner就是一个闭包,闭包=内部函数+环境,这里环境是x=10。闭包是为了解释调用不 阅读全文
posted @ 2017-12-26 23:15 Alos403 阅读(311) 评论(0) 推荐(0) 编辑
摘要: #函数定义def f(): print('love Q')f()##参数#形参和实参def add(a,b): print(a+b)add(7,5)def print_info(name,age): print('name:%s' % name) print('age:%d' % age)print 阅读全文
posted @ 2017-12-21 01:22 Alos403 阅读(185) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 下一页