GitHub 博客园 Nanakon

随笔分类 -  511.Python

__
摘要: 阅读全文

posted @ 2016-08-04 13:15 jzm17173 阅读(87) 评论(0) 推荐(0)

Python 生成器
摘要:生成器(generator)就是对象,在每次调用它的next()方法时返回一个值,直到它抛出StopIteration 要创建一个生成器需要做的一切只是写一个普通的包含yield 语句的 Python 函数。 Python 会检测对yield 的使用并将这个函数标记为一个生成器。当函数执行到yiel 阅读全文

posted @ 2016-08-04 00:12 jzm17173 阅读(165) 评论(0) 推荐(0)

函数
摘要:内部函数 闭包 匿名函数 阅读全文

posted @ 2016-08-04 00:05 jzm17173 阅读(83) 评论(0) 推荐(0)

函数参数
摘要:def menu(wine, entree, dessert='pudding'): return {'wine': wine, 'entree': entree, 'dessert': dessert} #位置参数 print(menu('bordeaux', 'beef', 'bagel')) #关键字参数 print(menu(entree='beef', dessert='b... 阅读全文

posted @ 2016-08-03 13:34 jzm17173 阅读(141) 评论(0) 推荐(0)

None
摘要: 阅读全文

posted @ 2016-08-03 13:24 jzm17173 阅读(92) 评论(0) 推荐(0)

使用range()生成自然数序列
摘要: 阅读全文

posted @ 2016-08-02 13:38 jzm17173 阅读(1682) 评论(0) 推荐(0)

使用zip()并行迭代
摘要: 阅读全文

posted @ 2016-08-02 13:31 jzm17173 阅读(106) 评论(0) 推荐(0)

代码结构
摘要: 阅读全文

posted @ 2016-08-01 13:35 jzm17173 阅读(142) 评论(0) 推荐(0)

进程
摘要:import subprocess subprocess.getoutput('date') # python3 getoutput方法 import multiprocessing import time import os def whoami(name): print("I'm %s, in process %s" % (name, os.getpid())) def... 阅读全文

posted @ 2016-07-31 21:38 jzm17173 阅读(102) 评论(0) 推荐(0)

sleep
摘要:import time print('......') time.sleep(5) print('......') 阅读全文

posted @ 2016-07-31 21:22 jzm17173 阅读(104) 评论(0) 推荐(0)

Python 推导式
摘要:列表推导式 字典推导式 集合推导式 生成器推导式 阅读全文

posted @ 2016-07-31 21:08 jzm17173 阅读(90) 评论(0) 推荐(0)

日期和时间
摘要:from datetime import datetime, date now = datetime.now() now #datetime.datetime(2016, 8, 13, 23, 7, 47, 768757) print(now.strftime('%Y-%m-%d %H:%M:%S')) #2016-08-13 23:08:04 # 检测是否是闰年 import cal... 阅读全文

posted @ 2016-07-28 23:38 jzm17173 阅读(94) 评论(0) 推荐(0)

目录
摘要:#使用mkdir()创建目录 import os os.mkdir('poems') print(os.path.exists('poems')) #使用rmdir()删除目录 import os os.rmdir('poems') print(os.path.exists('poems')) #使用listdir()列出目录内容 import os os.mkdir('poems') ... 阅读全文

posted @ 2016-07-28 19:50 jzm17173 阅读(103) 评论(0) 推荐(0)

文件
摘要:# 用open()创建文件 fout = open('oops.txt', 'wt') print('Oops, I created a file.', file=fout) fout.close() # 用exists()检查文件是否存在 import os print(os.path.exists('oops.txt')) # True print(os.path.exists(... 阅读全文

posted @ 2016-07-28 19:14 jzm17173 阅读(94) 评论(0) 推荐(0)

pip镜像源
摘要:pip是用国内镜像源 https://pypi.python.org/http://pypi.douban.com/simple/ http://mirrors.aliyun.com/pypi/simple/ 阅读全文

posted @ 2016-07-28 13:26 jzm17173 阅读(121) 评论(0) 推荐(0)

enumerate 枚举
摘要: 阅读全文

posted @ 2016-07-28 09:01 jzm17173 阅读(99) 评论(0) 推荐(0)

sys.argv
摘要:Python:sys.argv[]用法 阅读全文

posted @ 2016-07-28 08:59 jzm17173 阅读(111) 评论(0) 推荐(0)

webbrowser
摘要:可以控制浏览器 阅读全文

posted @ 2016-07-28 07:14 jzm17173 阅读(112) 评论(0) 推荐(0)

Web
摘要:Nginx 和Apache 等传统Web 服务器可以更快地处理静态文件。 阅读全文

posted @ 2016-07-25 13:36 jzm17173 阅读(163) 评论(0) 推荐(0)

#2# 三元引号
摘要: 阅读全文

posted @ 2016-07-22 15:48 jzm17173 阅读(144) 评论(0) 推荐(0)

导航

轻音