diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..a60cc3f
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,12 @@
+# These are supported funding model platforms
+
+github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
+patreon: pxiaoer
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/CNAME b/CNAME
new file mode 100644
index 0000000..bfb6cb6
--- /dev/null
+++ b/CNAME
@@ -0,0 +1 @@
+python.flypython.com
\ No newline at end of file
diff --git a/README.md b/README.md
index 0d362cf..0218d42 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,215 @@
-python
-======
-学习Python时的代码
+# FlyPython
+
+[python.flypython.com](https://python.flypython.com )
+
+
+## Python News
+
+- [python official](https://www.python.org/)
+- [medium](https://medium.com/tag/python)
+- reddit
+ - [python](https://www.reddit.com/r/Python/)
+ - [learn python](https://www.reddit.com/r/learnpython/)
+ - [python tips](https://www.reddit.com/r/pythontips/)
+ - [python coding](https://www.reddit.com/r/pythoncoding)
+
+
+
+## Python for LLM
+
+
+## Python Books
+
+#### Beginner
+- 《Python Crash Course: A Hands-On, Project-Based Introduction to Programming for begainners》
+ - ※※※※※
+ - [Amazon](https://www.amazon.com/Python-Crash-Course-Hands-Project-Based/dp/1593276036)
+
+- 《STARTING OUT WITH PYTHON (4TH EDITION)》
+ - ※※※※※
+ - [Amazon](https://www.amazon.com/Starting-Out-Python-Tony-Gaddis/dp/0134444329)
+
+- 《Automate the Boring Stuff with Python: Practical Programming for Total Beginners 》
+ - ※※※※※
+ - [Amazon](https://www.amazon.com/Automate-Boring-Stuff-Python-Programming/dp/1593275994)
+
+- 《Python Cookbook: Recipes for Mastering Python 3 Paperback 》
+ - ※※※※※
+ - [Amazon](https://www.amazon.co.uk/Python-Cookbook-David-Beazley/dp/1449340377)
+
+
+
+
+## Course
+
+
+#### Beginer
+ - [Python for Everybody](https://www.coursera.org/specializations/python)
+ - [Python 3 Programming](https://www.coursera.org/specializations/python-3-programming)
+
+
+
+## Data Science
+
+#### matplotlib
+- [AnatomyOfMatplotlib](https://github.com/matplotlib/AnatomyOfMatplotlib)
+
+
+## Github Top 45
+
+
+
+1. [Algorithm](#algorithm)
+1. [Guide](#guide)
+1. [Structure](#structure)
+1. [List](#list)
+1. [Class](#class)
+1. [Web Scraping](#web-scraping)
+1. [Automation](#automation)
+1. [Bot](#bot)
+1. [Spreasheet](#spreasheet)
+1. [Finance](#finance)
+1. [Blockchain](#blockchain)
+1. [Video Sythesizer](#video-sythesizer)
+1. [Performance](#performance)
+1. [Django](#django)
+1. [Flake](#flake)
+1. [NumPy](#numpy)
+1. [NashPy](#nashpy)
+1. [Markov Process](#markov-process)
+1. [Data Analysis](#data-analysis)
+1. [Get Started](#get-started)
+
+
+
+### Recommended Learning
+
+A) REST APIs: [Build professional REST APIs with Python, Flask, Flask-RESTful, and Flask-SQLAlchemy.](http://bit.ly/2nktytU) [12,602 recommends, 4.6/5 stars]
+
+B) Algorithmic Trading: [Python for Financial Analysis and Algorithmic Trading: Learn numpy , pandas , matplotlib , quantopian , finance.](http://bit.ly/2FfVW8G) [18,077 recommends, 4.6/5 stars]
+
+
+
+### Algorithm
+* [Interactive Python coding interview challenges (algorithms and data structures)](https://github.com/donnemartin/interactive-coding-challenges?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Algorithms: Minimal examples of data structures and algorithms in Python](https://github.com/keon/algorithms?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Pygorithm: A fun way to learn all major Python algorithms](http://pygorithm.readthedocs.io/en/latest?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Guide
+* [wtfPython: A collection of interesting, subtle, and tricky Python snippets](https://github.com/satwikkansal/wtfPython?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Structure
+* [Alice in Python projectland: A comprehensive guide for how to go from Python scripts to a packaged project.](http://veekaybee.github.io/2017/09/26/python-packaging?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### List
+* [Python List Comprehension Tutorial](http://www.datacamp.com/community/tutorials/python-list-comprehension?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Class
+* [Enriching Your Python Classes With Dunder (Magic, Special) Methods](https://dbader.org/blog/python-dunder-methods?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Web Scraping
+* [Web Scraping With Python: Scrapy, SQL, Matplotlib To Gain Web Data Insights](http://www.scrapingauthority.com/python-scrapy-mysql-and-matplotlib-to-gain-web-data-insights?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Advanced Web Scraping: Bypassing "403 Forbidden," captchas, and more](http://sangaline.com/post/advanced-web-scraping-tutorial?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Mastering Python Web Scraping: Get Your Data Back](https://hackernoon.com/mastering-python-web-scraping-get-your-data-back-e9a5cc653d88?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Automation
+* [Wedding at Scale: How I Used Twilio, Python and Google to Automate My Wedding](https://www.twilio.com/blog/2017/04/wedding-at-scale-how-i-used-twilio-python-and-google-to-automate-my-wedding.html?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [How I used Python to find interesting people to follow on Medium](https://medium.freecodecamp.org/how-i-used-python-to-find-interesting-people-on-medium-be9261b924b0?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Bot
+* [Making a Reddit + Facebook Messenger Bot](https://pythontips.com/2017/04/13/making-a-reddit-facebook-messenger-bot?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [My open source Instagram bot (written in Python) got me 2,500 real followers for $5 in server costs](https://medium.freecodecamp.com/my-open-source-instagram-bot-got-me-2-500-real-followers-for-5-in-server-costs-e40491358340?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Spreasheet
+* [Python Excel Tutorial: The Definitive Guide - Karlijn Willems](http://www.datacamp.com/community/tutorials/python-excel-tutorial?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Google Sheets and Python](https://www.youtube.com/watch?v=vISRn5qFrkM?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Finance
+* [Python For Finance: Algorithmic Trading](https://www.datacamp.com/community/tutorials/finance-python-trading?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Intro and Getting Stock Price Data - Python Programming for Finance p.1 - Sentdex](https://www.youtube.com/watch?v=2BrpKpWwT2A?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Analyzing Cryptocurrency Markets Using Python](https://blog.patricktriest.com/analyzing-cryptocurrencies-python?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Blockchain
+* [Learn Blockchains by Building One](https://hackernoon.com/learn-blockchains-by-building-one-117428612f46?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Let’s Build the Tiniest Blockchain](https://medium.com/crypto-currently/lets-build-the-tiniest-blockchain-e70965a248b?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Video Synthesizer
+* [Building a Video Synthesizer in Python](https://www.makeartwithpython.com/blog/video-synthesizer-in-python?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Performance
+* [A million requests per second with Python](https://medium.freecodecamp.com/million-requests-per-second-with-python-95c137af319?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Yes, Python is Slow, and I Don’t Care](https://hackernoon.com/yes-python-is-slow-and-i-dont-care-13763980b5a1?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Memoization in Python: How to Cache Function Results – Dan Bader](https://dbader.org/blog/python-memoization?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Django
+* [A Complete Beginner's Guide to Django - Part 1](https://simpleisbetterthancomplex.com/series/2017/09/04/a-complete-beginners-guide-to-django-part-1.html?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Build a REST API with Django – A Test Driven Approach: Part 1](https://scotch.io/tutorials/build-a-rest-api-with-django-a-test-driven-approach-part-1?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Flake
+* [The Big Ol' List of Rules](https://lintlyci.github.io/Flake8Rules?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Developing RESTful APIs with Python and Flask](https://auth0.com/blog/developing-restful-apis-with-python-and-flask?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### NumPy
+* [From Python to Numpy](http://www.labri.fr/perso/nrougier/from-python-to-numpy/?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Exploring Line Lengths in Python Packages](http://jakevdp.github.io/blog/2017/11/09/exploring-line-lengths-in-python-packages?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### NashPy
+* [Nashpy - Tutorial: building and finding the equilibrium for a simple game](http://nashpy.readthedocs.io/en/latest/tutorial?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Markov Process
+* [Simulating Chutes & Ladders in Python](https://jakevdp.github.io/blog/2017/12/18/simulating-chutes-and-ladders?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Data Analysis
+* [Exploring United States Policing Data Using Python](https://blog.patricktriest.com/police-data-python?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Analyzing 1000+ Greek Wines With Python](https://tselai.com/greek-wines-analysis.html?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [How to Generate FiveThirtyEight Graphs in Python](https://www.dataquest.io/blog/making-538-plots?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Playing with 80 Million Amazon Product Review Ratings Using Apache Spark with Python](http://minimaxir.com/2017/01/amazon-spark?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Fast GeoSpatial Analysis in Python](https://matthewrocklin.com/blog//work/2017/09/21/accelerating-geopandas-1?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [Planet: Understanding the Amazon from Space, 1st Place Winner's Interview](http://blog.kaggle.com/2017/10/17/planet-understanding-the-amazon-from-space-1st-place-winners-interview?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
+
+
+### Get Started
+* [Learning Python: From Zero to Hero](https://medium.freecodecamp.org/learning-python-from-zero-to-hero-120ea540b567?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [A List of Non Trivial Python Exercises](https://www.ynonperek.com/2017/09/21/python-exercises?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [API Design: Think First, Code Later](https://www.ckl.io/blog/api-design-think-first-code-later?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [The Hitchhiker’s Guide to Machine Learning in Python](https://medium.freecodecamp.org/the-hitchhikers-guide-to-machine-learning-algorithms-in-python-bfad66adb378?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [How to learn Python programming: 6 experienced Python developers share their learning tips](https://coolpythoncodes.com/best-way-learn-python-programming?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+* [ you can find out How Did Python Become A Data Science Powerhouse?](https://www.youtube.com/watch?v=9by46AAqz70?utm_source=mybridge&utm_medium=email&utm_campaign=read_more)
+
diff --git a/README_cn.md b/README_cn.md
new file mode 100644
index 0000000..2e93c10
--- /dev/null
+++ b/README_cn.md
@@ -0,0 +1,841 @@
+# FlyPython
+
+https://flypython.com
+
+
+## Python新闻
+
+- [python官方](https://www.python.org/)
+- [realpython](https://realpython.com)
+- [medium](https://medium.com/tag/python)
+- reddit
+ - [python](https://www.reddit.com/r/Python/)
+ - [learn python](https://www.reddit.com/r/learnpython/)
+ - [python tips](https://www.reddit.com/r/pythontips/)
+
+
+## Python书籍列表
+
+#### 初学者
+- 《Python编程从入门到实践》
+- 《Python编程快速上手-让繁琐工作自动化》
+- 《Python学习手册》
+
+
+#### 中级
+- 《流畅的Python》
+- 《Python Ticks: A Buufect of Awesome》
+- 《Effective Python: 59 Specific ways to 》
+-
+
+#### 实践
+- 《Python编程》
+- 《Python极客项目编程》
+- 《Python核心编程》
+
+
+#### 高级
+- 《Python Cookbook》
+
+
+
+#### 参考资源
+- https://pythonbooks.org/
+
+
+## Python课程列表
+
+#### 初学者
+
+- [Python for Everybody](https://www.coursera.org/specializations/python)
+
+
+## Github Top 45
+
+REST API:使用 Python,Flask,Flask-RESTful 和 Flask-SQLAlchemy 构建专业的 REST API [12,602 个推荐,4.6 / 5 星]
+
+链接:https://www.udemy.com/rest-api-flask-and-python/
+
+
+
+算法交易:用于财务分析和算法交易的 Python,主要学习包括 numpy,pandas,matplotlib,quantopian,finance [8,077 个推荐,4.6 / 5 星]
+
+链接:https://www.udemy.com/python-for-finance-and-trading-algorithms/
+
+
+
+年度开源 Python 项目 [平均 4,078 星]
+
+
+链接:https://medium.mybridge.co/30-amazing-python-projects-for-the-past-year-v-2018-9c310b04cdb3
+
+
+
+Python 算法
+
+
+1. 回顾 Python 交互式编码中所要面对的挑战 (算法和数据结构)
+
+ 本文对算法编码和数据结构中的问题提出了简单易懂又切实可行的方案。
+
+ 作者:Donne Martin;[github-11811 星]
+
+ 链接:https://github.com/donnemartin/interactive-coding-challenges
+
+
+
+2. Python 中算法和数据结构的最小样本
+
+ 如何让 Python 中的数据结构和算法最小、最干净?
+
+ 作者:keon;[github-10271 星]
+
+ 链接:https://github.com/keon/algorithms
+
+
+
+3. 最重要的 Python 算法 --Pygorithm
+
+ Pygorithm 是一个纯 Python 风格编写的模块,通过导入所需的算法,获得相应的代码、时间复杂性等。这是一个开始学习 Python 编程的好方法,能够帮助初学者学习并实现 Python 中所有算法。
+
+ 作者:Satwik Kansal;[github-3156 星]
+
+ 链接:http://pygorithm.readthedocs.io/en/latest/
+
+
+
+Python 综合指南
+
+4. 一个有趣又鲜为人知的 Python 代码片段集合 —wtfPython
+
+ 作者:Satwikkansal;[github-4,933 星]
+
+ 链接:https://github.com/satwikkansal/wtfPython
+
+
+
+
+
+Python 的脚本结构
+
+5. 一个关于如何从 Python 脚本到打包项目的标准化指南
+
+ 作者:Courtesy of Vicki
+
+ 链接:http://veekaybee.github.io/2017/09/26/python-packaging
+
+
+
+
+
+Python 中的列表
+
+6. Python 列表生成器的教程
+
+ 在这份教程中,你将能够学习到如何在 Python 中有效地使用列表生成器来创建列表,替换 (嵌套) for 循环以及使用 map (), filter (), reduce () 函数等。
+
+ 文章首先简单回顾了 Python 中列表的基本概念,并与 Python 中其他的数据结构进行比较。接着讲解了列表生成器的学习。文章还讲解了 Python 列表背后的数学知识,创建列表生成器的方法,以及如何在 for 循环或 lambda 隐函数中重写它们。
+
+ 作者:Karlijn Willems
+
+ 链接:https://www.datacamp.com/community/tutorials/python-list-comprehension
+
+
+
+Python 中的类
+
+7. 如何使用 Dunder (Magic、Special) 方法来丰富你的 Python 类
+
+ Dunker 是 Python 中的一种特殊方法,通过双下划线开始和结束的形式存在,例如__init__来丰富类的预定义方法。
+
+ 作者:Dan Bader
+
+ 链接:https://dbader.org/blog/python-dunder-methods
+
+
+
+
+Python 中的网页抓取
+
+8. 如何使用 Python 中的 Scrapy、SQL 和 Matplotlib 等库进行网页抓取,并获取网页数据分析
+
+ 你可以通过这篇文章学习到网页爬取知识,并用于实践中。
+
+ 作者:ScrapingAuthority
+
+ 链接:http://www.scrapingauthority.com/python-scrapy-mysql-and-matplotlib-to-gain-web-data-insights/
+
+
+
+9. 高级的网页抓取教程:绕过 “403 禁止”,验证码等问题
+
+ 作者:Evan Sangaline
+
+ 链接:http://sangaline.com/post/advanced-web-scraping-tutorial/
+
+
+
+10. 掌握 Python 的网页抓取技巧来获取你所需要的数据
+
+ 作者:Lauren Glass 和 Hackernoon
+
+ 链接:https://hackernoon.com/mastering-python-web-scraping-get-your-data-back-e9a5cc653d88
+
+
+
+
+
+Python 中的自动化操作
+
+11. 如何使用 Twilio、Python 和 Google 自动化婚礼的进程
+
+作者:Thomas Curtis
+
+链接:https://www.twilio.com/blog/2017/04/wedding-at-scale-how-i-used-twilio-python-and-google-to-automate-my-wedding.html
+
+
+
+12. 如何用 Python 在 Medium 上找到有趣的人
+
+作者:Radu Raicea 和 freeCodeCamp。
+
+链接:https://medium.freecodecamp.org/how-i-used-python-to-find-interesting-people-on-medium-be9261b924b0
+
+
+
+
+
+Python 中的 Bot
+13. 制作 Reddit+Facebook 的信息箱
+
+作者:
+
+Yasoob Khalid
+
+链接:
+
+https://pythontips.com/2017/04/13/making-a-reddit-facebook-messenger-bot/
+
+
+
+14. 我在 Instagram 上用 Python 写的开源机器人 (让我拥有了 2500 个粉丝,所花的服务器成本只有 5 美元)
+
+作者:
+
+TimG
+
+链接:
+
+https://medium.freecodecamp.org/my-open-source-instagram-bot-got-me-2-500-real-followers-for-5-in-server-costs-e40491358340
+
+
+
+Python 中的电子表格
+
+15. 权威指南:Python 的 Excel 教程
+
+通过这个教程,你可以了解如何使用 Python 读取和导入 Excel 文件,如何将数据写入这些电子表格。
+
+作者:
+
+Karlijn Willems
+
+链接:
+
+https://www.datacamp.com/community/tutorials/python-excel-tutorial
+
+
+
+16. Python 和 Googgle 电子表格
+
+作者:
+
+Brent Schooley
+
+链接:
+
+https://www.youtube.com/watch?v=vISRn5qFrkM
+
+
+
+
+
+Python 中的金融应用
+
+17. Python 中的金融:算法交易
+
+这是一份 Python 与金融应用的教程,在此你能学习到算法交易的基本知识及相关内容。
+
+作者:
+
+Karlijn Willems
+
+链接:
+
+https://www.datacamp.com/community/tutorials/finance-python-trading
+
+
+
+18. Python 中的金融教程 — 股票价格及相关数据介绍
+
+作者:
+
+Harrison Kinsley
+
+链接:
+
+https://www.youtube.com/watch?v=2BrpKpWwT2A
+
+
+
+19. 用 Python 分析加密货币市场
+
+
+
+比特币市场是如何表现?加密货币价值突然出现高峰和低谷的原因是什么?不同 altcoins 市场是不可分割的或基本独立的?我们如何预测接下来会发生什么?
+
+
+
+这篇文章将简单地介绍如何使用 Python 来分析加密货币。文章通过一个简单的 Python 脚本来检索,分析和可视化不同加密货币上的数据。在这个过程中,文章还将揭示这些波动剧烈的市场行为以及一个有趣的演变趋势。
+
+
+
+作者:
+
+Patrick Triest
+
+链接:
+
+https://blog.patricktriest.com/analyzing-cryptocurrencies-python/
+
+
+
+
+
+Python 中的区块链
+
+
+
+20. 学习并构建一个区块链
+
+
+
+毫无疑问,区块链这项新颖的技术是计算的奇迹。区块链技术的出现引发了新的全数字货币,如比特币和莱特币,而这些货币并非由中央当局发行或管理。区块链也以 Ethereum 这样的技术形式革命化了分布式计算,并引入了智能合约等有趣的概念。
+
+
+
+这篇文章将会帮助你学习并理解区块链的工作原理。通过这篇教程,你将学习到一个功能强大的区块链,并掌握它们的工作流程。
+
+
+
+作者:
+
+Daniel van Flymen 和 Hackernoon
+
+链接:
+
+https://hackernoon.com/learn-blockchains-by-building-one-117428612f46
+
+
+
+21. 如何构建一个最小的区块链
+
+
+
+本文将用少于 50 行的代码 (Python2) 来创建一个最简单、最小的区块链。
+
+
+
+作者:
+
+Gerald Nash
+
+链接:
+
+https://medium.com/crypto-currently/lets-build-the-tiniest-blockchain-e70965a248b
+
+
+
+
+
+Python 中的视频合成
+
+
+
+22. 用 Python 构建一个视频合成器
+
+
+
+视频合成器是利用音频输入来创建视觉信号的设备,自上世纪 60 年代以来,已有很长的历史。
+
+
+
+这篇文章将用 Python 编写一个基本的视频合成器,并使用 aubio 进行 Onset 目标检测。
+
+
+
+作者:
+
+Kirk Kaiser
+
+链接:
+
+https://www.makeartwithpython.com/blog/video-synthesizer-in-python/
+
+
+
+
+
+Python 的性能
+
+
+
+23. 用 Python 处理每秒 100 万个请求
+
+
+
+用 Python 每秒能够达到 100 万个请求吗?为了节省服务器价格,最近很多公司正在从 Python 向其他编程语言中迁移。但实际并不需要。
+
+
+
+Python 社区最近在性能提升方面做了很多工作。CPython 3.6 通过新的字典提高了整体解释器的性能。由于引入了更快的调用约定和字典查找缓存,CPython 3.7 将会更快。
+
+
+
+对于数字处理任务,你可以使用 PyPy 进行代码编译。你还可以运行 NumPy 的测试套件,该测试套件现在已经改进了 Python 与 C 语言扩展的整体兼容性。在随后的更新版本中,PyPy 预计将与 Python 3.5 兼容。
+
+
+
+作者:
+
+Paweł Piotr Przeradowski。
+
+链接:
+
+https://medium.freecodecamp.org/million-requests-per-second-with-python-95c137af319
+
+
+
+24. “Python 很慢,但我不在乎”
+
+
+
+这篇文章将介绍一些关于 Python 中 asyncio 的内容,并讨论有关 Python 速度的问题。
+
+
+
+作者:
+
+Nick Humrich
+
+链接:
+
+https://hackernoon.com/yes-python-is-slow-and-i-dont-care-13763980b5a1
+
+
+
+25. Python 中的缓存:如何缓存函数的结果
+
+
+
+文章将介绍一种快捷的方法来加速 Python 记忆代码。你将看到何时以及如何运用 Python 记忆代码。记忆代码优化你的程序,在某些情况下会加速你的代码运行。
+
+
+
+链接:
+
+https://dbader.org/blog/python-memoization
+
+
+
+
+
+Python 中的 Django 框架
+
+
+
+26. 七步骤带你完整地学习 Django
+
+
+
+Django 是用 Python 编写的一个 Web 框架。这篇文章是介绍 Django 基础知识的系列教程,共分为七个部分,将分别从安装,准备开发环境,模型,视图,模板,URL 到更高级的主题(如迁移,测试和部署)出发,详细探讨所有的基本概念。
+
+
+
+作者:
+
+Vitor Freitas
+
+链接:
+
+https://simpleisbetterthancomplex.com/series/2017/09/04/a-complete-beginners-guide-to-django-part-1.html
+
+
+
+27. 使用 Django 构建 REST API 的测试驱动方法:第一部分
+
+
+
+这篇文章将介绍如何利用 Django 来构建一个 REST API 的测试驱动,并详细介绍了每个步骤。
+
+
+
+作者:
+
+Jee Githinji Gikera 和 Scotch Development
+
+链接:
+
+https://scotch.io/tutorials/build-a-rest-api-with-django-a-test-driven-approach-part-1
+
+
+
+
+
+Python 中的 Flake
+
+
+
+28. OI’List 规则
+
+
+
+这篇博文中我们将介绍 Flake8(pyflakes,pycodestyle 和 mccabe)中的每个规则及相对应的示例。
+
+
+
+链接:
+
+https://lintlyci.github.io/Flake8Rules/
+
+
+
+29. 使用 Python 和 Flask 开发 RESTful API
+
+
+
+本文包括以下几部分:为什么用 Python;什么是 Flask;引导 Flask 应用程序
+
+用 Flask 创建一个 RESTful 端点;用 Python 类映射模型;用 Marshmallow 进行序列化和反序列化对象;Dockerizing Flask 应用程序;用 Auth0 保护 Python API
+
+
+
+作者:
+
+Bruno Krebs
+
+链接:
+
+https://auth0.com/blog/developing-restful-apis-with-python-and-flask/
+
+
+
+
+
+Python 中的 Numpy
+
+
+
+30. 从 Python 到 Numpy
+
+
+
+本文通过一种新颖的方式,向量化地集中讲解了如何从 Python 迁移到 Numpy 的学习。另外,本文还包括一些很少提到的使用技巧。
+
+
+
+链接:
+
+http://www.labri.fr/perso/nrougier/from-python-to-numpy/
+
+
+
+31. 探索 Python 每种工具包的行长度
+
+
+
+本文探索了 Python 的流行包,如 NumPy,SciPy,Pandas,Scikit-Learn,Matplotlib,AstroPy 等。
+
+
+
+作者:
+
+Jake VanderPlas
+
+链接:
+
+http://jakevdp.github.io/blog/2017/11/09/exploring-line-lengths-in-python-packages/
+
+
+
+
+
+Python 中的 NashPy
+
+
+
+32. NashPy 教程 — 建立并找到一种简单的游戏平衡
+
+
+
+博弈论是用来研究理性主体之间的战略互动:当双方试图采用对各自最有益的方式来完成某件事情时,对双方互动行为的研究。这篇文章将采用 Python 中的 NashPy 来研究这种双方博弈的互动行为。
+
+
+
+链接:
+
+http://nashpy.readthedocs.io/en/latest/tutorial/
+
+
+
+
+
+Python 中的马尔可夫过程
+
+
+
+33. 用 Python 模拟 Chutes 和 Ladders
+
+
+
+这篇文章将通过 Chutes 和 Ladders 游戏的例子,建立模型并阐述马尔可夫过程的原理。整个分析过程附有 Python 源码,感兴趣的读者可以尝试一下。
+
+
+
+作者:
+
+Jake VanderPlas
+
+链接:
+
+http://jakevdp.github.io/blog/2017/12/18/simulating-chutes-and-ladders/
+
+
+
+
+
+Python 中的数据分析
+
+
+
+34. 用 Python 分析美国联邦政治行为
+
+
+
+科学,政治,个人意见和社会政策的交集可能呈现相当复杂的情况。思想和学科的交汇点通常充斥着有争议的观点和基于信仰但缺乏经验证据的议程。这时,数据科学在这方面就显得特别重要,因为它提供了一种以实际事实为基础的考察世界的方法,能够深入了解我们今天所面临的一些最重要的问题。
+
+
+
+这篇文章我们将用 Python 来分析美国联邦政府的一些政治行为,深入了解政治背后所隐藏的故事。
+
+
+
+作者:
+
+Patrick Triest
+
+链接:
+
+https://blog.patricktriest.com/police-data-python/
+
+
+
+35. 用 Python 分析 1000 + 的希腊葡萄酒
+
+
+
+作者:
+
+Florents Tselai
+
+链接:
+
+https://tselai.com/greek-wines-analysis.html
+
+
+
+
+
+36. 如何用 Python 生成 FiveThirtyEight 图
+
+
+
+这篇文章将用 Python 的 matplotlib 和 pandas,来学习并查看 FiveThirtyEight(FTE)可视化的核心部分,并教会你使用 Python 来为自己的数据进行可视化。
+
+
+
+作者:
+
+Josh Devlin
+
+链接:
+
+https://www.dataquest.io/blog/making-538-plots/、
+
+
+
+
+
+37. 使用 Apache Spark 和 Python 为 8000 万 Amazon 产品进行评价打分
+
+
+
+作者编写了一个简单的 Python 脚本,将亚马逊产品评论数据集中的每类评分数据进行整合,并对这些 Amazon 产品评论数据进行分析打分,以发现用户的喜好。
+
+
+
+作者:
+
+Max Woolf
+
+链接:
+
+http://minimaxir.com/2017/01/amazon-spark/
+
+
+
+
+
+38. 使用 Python 进行地理空间分析
+
+
+
+作者:
+
+Matthew Rocklin
+
+链接:
+
+https://matthewrocklin.com/blog//work/2017/09/21/accelerating-geopandas-1
+
+
+
+
+
+39. 星球:从太空中了解亚马逊,来自 Kaggle 头奖获奖者的采访
+
+
+
+文章采访了 Kaggle 的 “星球:从太空中了解亚马逊” 竞赛的获奖者,内容包括他如何使用 11 个微调的卷积神经网络,标签关联的结构模型,以及如何避免过拟合现象等。
+
+
+
+作者:
+
+Edwin Chen
+
+链接:
+
+http://blog.kaggle.com/2017/10/17/planet-understanding-the-amazon-from-space-1st-place-winners-interview/
+
+
+
+
+
+Python 入门
+
+
+
+40. 从零开始学习 Python
+
+
+
+Python 的创建者 Guido van Rossum 曾说过,“Python 是一个高级编程语言,其核心设计理念是让代码具有高度的可读性和简单的语法,程序员可以用几行代码表达自己的想法。”
+
+
+
+作者:
+
+TK
+
+链接:
+
+https://medium.freecodecamp.org/learning-python-from-zero-to-hero-120ea540b567
+
+
+
+
+
+41. 重要的 Python 练习清单
+
+
+
+这篇文章列出了一些重要的练习项目,包括 Python 语言本身和标准库的练习。文章中还有 Python 中不同主题模块的知识。
+
+
+
+作者:
+
+Ynon Perek
+
+链接:
+
+https://www.ynonperek.com/2017/09/21/python-exercises/
+
+
+
+
+
+42. API 的设计原则:先思考再编码
+
+
+
+API 是定义应用程序接口的通用术语,换句话说,就是用户(人或机器)与程序的交互接口。在 Web 开发世界中,API 通常是一个网站,其中包含一系列端点,用于响应客户端请求和结构化文本数据。这篇文章将告诉你为什么以及如何设计一个正确的 API,如何将自己的思想植入到 API 的设计中来构建属于你自己的 API。
+
+
+
+作者:
+
+Jonatas Baldin
+
+链接:
+
+https://www.ckl.io/blog/api-design-think-first-code-later
+
+
+
+
+
+43. Python 机器学习指南
+
+
+
+本文将通过清晰地解释和有效的练习,来帮助你深度理解相关的机器学习算法。
+
+
+
+作者:
+
+Conor Dewey
+
+链接:
+
+https://medium.freecodecamp.org/the-hitchhikers-guide-to-machine-learning-algorithms-in-python-bfad66adb378
+
+
+
+
+
+44. 如何学习 Python 编程:6 位经验丰富的 Python 开发者分享了他们的观点
+
+
+
+对于当下热门的 Python 语言,有太多的教程、书籍、视频和博客文章资源,然而如此多的冗余资料,你该如何选择最佳的方式开始你的 Python 学习之旅呢?这篇文章列出了 6 位 Python 专家分享的学习经验,相信这对于迷茫中的你来说,将受益匪浅。
+
+
+
+链接:
+
+https://coolpythoncodes.com/best-way-learn-python-programming
+
+
+
+45. 如何用 Python 实现强大的数据分析
+
+Python 是数据分析的最佳编程语言,这得益于它自带的依赖库。依赖库能够存储,操纵数据,并从数据中获得核心信息,因而在数据科学领域被广泛使用并展现出强大的功能。本文介绍了 Python 在数据科学领域的应用历史以及最新发展。
+
+作者:Jake VanderPlas
+
+链接:https://www.youtube.com/watch?v=9by46AAqz70
+
+
diff --git a/_config.yml b/_config.yml
new file mode 100644
index 0000000..2f7efbe
--- /dev/null
+++ b/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-minimal
\ No newline at end of file
diff --git a/datastruct/binarysearch.py b/datastruct/binarysearch.py
deleted file mode 100644
index fa6a1e2..0000000
--- a/datastruct/binarysearch.py
+++ /dev/null
@@ -1,25 +0,0 @@
-def BinarySearch(l,key):
- low=0
- high=len(l)-1
- i=0
- while(low <= high):
- i = i+1
- mid = low + ((high-low)>>1)
- if(l[mid] < key):
- low = mid + 1
- elif (l[mid] > key):
- high = mid -1
- else:
- print "use %d times" % i
- return mid
- return -1
-
-if __name__ == "__main__":
- l=[1,4,5,6,7,8,9,44,333,2233]
- print l
- print BinarySearch(l,4)
- print BinarySearch(l,44)
- print BinarySearch(l,8)
- print BinarySearch(l,2233)
- print BinarySearch(l,77)
-
diff --git a/datastruct/btree.py b/datastruct/btree.py
deleted file mode 100644
index 69434e8..0000000
--- a/datastruct/btree.py
+++ /dev/null
@@ -1,62 +0,0 @@
-class BTree:
- def __init__(self,value):
- self.left=None
- self.data=value
- self.right=None
-
- def insertLeft(self,value):
- self.left=BTree(value)
- return self.left
-
- def insertRight(self,value):
- self.right=BTree(value)
- return self.right
-
- def show(self):
- print self.data
-
-def preorder(node):
- if node.data:
- node.show()
- if node.left:
- preorder(node.left)
- if node.right:
- preorder(node.right)
-
-def inorder(node):
- if node.data:
- if node.left:
- inorder(node.left)
- node.show()
- if node.right:
- inorder(node.right)
-
-def postorder(node):
- if node.data:
- if node.left:
- postorder(node.left)
- if node.right:
- postorder(node.right)
- node.show()
-
-if __name__ == "__main__":
-
- Root=BTree("root")
- A=Root.insertLeft("A")
- C=A.insertLeft("C")
- D=C.insertRight("D")
- F=D.insertLeft("F")
- G=D.insertRight("G")
- B=Root.insertRight("B")
- E=B.insertRight("E")
-
- print "pre-traversal"
- preorder(Root)
-
- print "in-traversal"
- inorder(Root)
-
- print "post-traversal"
- postorder(Root)
-
-
diff --git a/datastruct/graph.py b/datastruct/graph.py
deleted file mode 100644
index 834670b..0000000
--- a/datastruct/graph.py
+++ /dev/null
@@ -1,35 +0,0 @@
-def searchGraph(graph,start,end):
- results=[]
- generatePath(graph,[start],end,results)
- results.sort(lambda x,y:cmp(len(x),len(y)))
- return results
-
-def generatePath(graph,path,end,results):
- state=path[-1]
- if state == end:
- results.append(path)
- else:
- for arc in graph[state]:
- if arc not in path:
- generatePath(graph,path+[arc],end,results)
-
-
-if __name__ == "__main__":
- Graph={
- 'A':['B','C','D'],
- 'B':['E'],
- 'C':['D','F'],
- 'D':['B','E','G'],
- 'E':[],
- 'F':['D','G'],
- 'G':['E']
- }
- r = searchGraph(Graph,'A','D')
- print "A to D"
- for i in r:
- print i
-
- r=searchGraph(Graph,'A','E')
- print "A to E"
- for i in r:
- print i
diff --git a/datastruct/queue.py b/datastruct/queue.py
deleted file mode 100644
index 64da3e4..0000000
--- a/datastruct/queue.py
+++ /dev/null
@@ -1,43 +0,0 @@
-class Queue:
- def __init__(self,size=20):
- self.queue=[]
- self.size=size
- self.end=-1
-
- def setSize(self,size):
- self.size=size
-
- def In(self,element):
- if self.end < self.size -1:
- self.queue.append(element)
- self.end = self.end + 1
- else:
- raise "QueueFull"
-
- def Out(self):
- if self.end != -1:
- element = self.queue[0]
- self.queue=self.queue[1:]
- self.end = self.end-1
- return element
- else:
- raise "QueueEmpty"
-
- def End(self):
- return self.end
-
- def empty(self):
- self.queue=[]
- self.end=-1
-
-if __name__ == "__main__":
-
- queue=Queue()
- for i in range(10):
- queue.In(i)
- print queue.End()
-
- for i in range(10):
- print queue.Out()
-
-
diff --git a/datastruct/sort.py b/datastruct/sort.py
deleted file mode 100644
index b190701..0000000
--- a/datastruct/sort.py
+++ /dev/null
@@ -1,78 +0,0 @@
-class BTree:
- def __init__(self,value):
- self.left=None
- self.data=value
- self.right=None
-
- def insertLeft(self,value):
- self.left=BTree(value)
- return self.left
-
- def insertRight(self,value):
- self.right=BTree(value)
- return self.right
-
- def show(self):
- print self.data
-
-def inorder(node):
- if node.data:
- if node.left:
- inorder(node.left)
- node.show()
- if node.right:
- inorder(node.right)
-
-
-def rinorder(node):
- if node.data:
- if node.right:
- rinorder(node.right)
- node.show()
- if node.left:
- rinorder(node.left)
-
-def insert(node,value):
- if value > node.data:
- if node.right:
- insert(node.right,value)
- else:
- node.insertRight(value)
- else:
- if node.left:
- insert(node.left,value)
- else:
- node.insertLeft(value)
-
-
-if __name__ == "__main__":
-
- l=[88,11,2,33,22,4,55,33,221,34]
- Root=BTree(l[0])
- node=Root
- for i in range(1,len(l)):
- insert(Root,l[i])
-
- print "1---->10"
- inorder(Root)
- print "10--->1"
- rinorder(Root)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/datastruct/stack.py b/datastruct/stack.py
deleted file mode 100644
index e5b65ce..0000000
--- a/datastruct/stack.py
+++ /dev/null
@@ -1,59 +0,0 @@
-class Stack:
- def __init__(self,size=20):
- self.stack= []
- self.size= size;
- self.top= -1
-
- def setSize(self,size):
- self.size=size;
-
- def push(self,element):
- if self.isFull():
- raise "StackOverflow"
- else:
- self.stack.append(element)
- self.top = self.top + 1
-
- def pop(self):
- if self.isEmpty():
- raise "StackUnderflow"
- else:
- element=self.stack[-1]
- self.top=self.top-1;
- del self.stack[-1]
- return element
-
- def Top(self):
- return self.top
-
- def empty(self):
- self.stack=[]
- self.top=-1
-
- def isEmpty(self):
- if self.top == -1:
- return True
- else:
- return False
-
- def isFull(self):
- if self.top == self.size-1:
- return True
- else:
- return False
-
-if __name__ == "__main__":
-
- stack=Stack()
-
- for i in range(10):
- stack.push(i)
- print stack.Top()
-
- for i in range(10):
- print stack.pop()
-
- stack.empty()
- print stack.Top()
-
-
diff --git a/expand/1.py b/expand/1.py
deleted file mode 100644
index 3239a25..0000000
--- a/expand/1.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#a = '19'
-#print "please input a int number in 1-100"
-#x = raw_input()
-#if a != x:
-# print "sorry you are wrong!\ninput again:"
-# x = raw_input()
-#else
-# print "you are right"
-#raw_input()
-
-from random import randint
-
-def printNum():
-
- sInput = raw_input(u"请输入你猜的数字(1-100):")
-
- try:
- nInput = int(sInput)
- except (ValueError,TypeError),diag:
- print str(diag)
-
- if(nInput < 1 or nInput > 100):
- print u"你数字不在范围之内,请重新输入"
-
- return nInput
-
-def main():
-
- nValue = randint(1,100)
- nInput = printNum()
- nTotal = 1
-
- while(nValue!= nInput):
-
- if (nValue > nInput):
- print u"你猜的数小了"
-
- elif (nValue < nInput):
- print u"你猜的数大了"
-
- nTotal += 1
- nInput=printNum()
-
- print u"恭喜你猜对了"
- print u"你直到猜对 共猜了%d次" % nTotal
-
- if nTotal < 10:
- print u"恭喜,你的成绩超过了平均水平"
- else:
- print u"很遗憾,你成绩没达到平均水平"
-
-
-if __name__ == "__main__":
- main()
diff --git a/expand/2.py b/expand/2.py
deleted file mode 100644
index 8f1d16f..0000000
--- a/expand/2.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#s = raw_input()
-#i = 0
-#for i in s:
-# print i
-#raw_input()
-
-#扩展成在字符串中把特定字符替换成规定字符
-import re
-def printReplace(srcStr,word):
- for letter in srcStr:
- if letter == word:
- srcStr = srcStr.replace(letter,'!') #字符串不可更改
- return srcStr
-
-def printReplace_re(srcStr,word):
- srcStr=re.sub(word,'!',srcStr)
- return srcStr
-
-def main():
- srcStr = raw_input(u"请输入一个字符串:")
- destStr=printReplace_re(srcStr,'i')
- print destStr
-
-
-if __name__ == "__main__":
- main()
-
diff --git a/primer/10/card.py b/primer/10/card.py
deleted file mode 100644
index e6bac33..0000000
--- a/primer/10/card.py
+++ /dev/null
@@ -1,33 +0,0 @@
-def safe_float(obj):
- try:
- retval = float(obj)
- except (ValueError,TypeError),diag:
- retval = str(diag)
- return retval
-
-def main():
- log = open("cardlog.txt","w")
- try:
- ccfile = open("carddata.txt","r")
- except IOError,e:
- log.write("no txns this \n")
- log.close()
- return
- txns = ccfile.readlines()
- ccfile.close()
- total = 0.00
- log.write("account log:\n")
-
- for eachTxn in txns:
- result = safe_float(eachTxn)
- if isinstance(result,float):
- total += result
- log.write("data ....processed\n")
- else:
- log.write("ignored: %s" % result)
- print "$%.2f (new balance)" % (total)
- log.close()
-
-if __name__ == '__main__':
- print "run"
- main()
diff --git a/primer/10/myexc.py b/primer/10/myexc.py
deleted file mode 100644
index 0e3245f..0000000
--- a/primer/10/myexc.py
+++ /dev/null
@@ -1,104 +0,0 @@
-
-import os,socket,errno,types,tempfile
-
-class NetworkError(IOError):
- pass
-
-class FileError(IOError):
- pass
-
-def updArgs(args,newarg=None):
- if isinstance(args,IOError):
- myargs =[]
- myargs.extend([arg for arg in args])
- else:
- myargs = list(args)
-
- if newarg:
- myargs.append(newarg)
-
- return tuple(myargs)
-
-def fileAargs(file,mode,agrs):
- if args[0] == errno.EACCES and \
- 'access' in dir(os):
- perms = ''
- perms = {'r':os.R_OK,'w':os.W_OK,'x':os.X_OK}
- pkeys = permd.keys()
- pkeys.sort()
- pkeys.reverse()
-
- for eachPerm in 'rwx':
- if os.access(file,permd[eachPerm]):
- perms += eachPerm
- else:
- perms += '-'
-
- if isinstance(args,IOError):
- myargs = []
- myargs.extend([arg for arg in args])
- else:
- myargs = list(args)
-
- myargs[1] = "'%s' %s (perms:'%s')" % (mode,myargs[1],perms)
-
- myargs.append(args.filename)
-
- else:
- myargs = args
- return tuple(myargs)
-
-def myconnnect(sock,host,port):
- try:
- sock.connect((hosy,port))
- except socket.error,args:
- myargs = updArgs(args)
- if len(myargs) == 1:
- myargs = (errno.ENXIO,myargs[0])
-
- raise NetworkError,\
- updArgs(myargs,host +":" + str(port))
-def myopen(file,mode ="r"):
- try:
- fo = open(file,mode)
- except IOError,args:
- raise FileError,fileArgs(file,mode,args)
- return fo
-
-def testfile():
- file = mkdtemp()
- f = open(file,"w")
- f.close()
-
- for eachTest in ((0,"r"),(0100,"r"), \
- (0400,"w"),(0500,"w")):
- try:
- os.chmod(file,eachTest[0])
- f=myopen(file,eachTest[1])
-
- except FileError,args:
- print "%s: %s" % \
- (args.__class__.__name__,args)
- else:
- print file,"open ok..perm ignored"
- f.close()
- os.chmod(file,0777)
- os.unlink(file)
-def testnet():
- s = socket.socket(socket.AF_INET.socket.SOCK_STREAM)
- for eachHost in ("deli","www"):
- try:
- myconnect(s,"deli",8080)
- except NetworkError,args:
- print "%s:%s" %\
- (args.__class__.__name__,args)
-if __name__ == "__main__":
- testfile()
- testnet()
-
-
-
-
-
-
-
diff --git a/primer/11/Gui.py b/primer/11/Gui.py
deleted file mode 100644
index 6bff1f6..0000000
--- a/primer/11/Gui.py
+++ /dev/null
@@ -1,17 +0,0 @@
-
-from functools import partial
-import Tkinter
-
-root=Tkinter.Tk()
-MyButton = partial(Tkinter.Button,root,
- fg="white",bg="blue")
-b1= MyButton(text="button 1")
-b2=MyButton(text="button 2")
-#qb=MyButton(text="QUIT",bg="red",
- # command=root.quit)
-
-b1.pack()
-b2.pack()
-#qb.pack(file=Tkinter.X,expand= True)
-root.title("PFAs!")
-root.mainloop()
diff --git a/primer/11/deco.py b/primer/11/deco.py
deleted file mode 100644
index 21d7389..0000000
--- a/primer/11/deco.py
+++ /dev/null
@@ -1,22 +0,0 @@
-
-from time import ctime,sleep
-
-def tsfunc(func):
- def wrappedFunc():
- print "[%s] %s() called" % \
- (ctime(),func.__name__)
- return func()
- return wrappendFunc
-
-@tsfunc
-def foo():
- pass
-
-foo()
-sleep(4)
-
-for i in range(2):
- sleep(1)
- foo()
-
-
diff --git a/primer/11/easyMath.py b/primer/11/easyMath.py
deleted file mode 100644
index e14d53b..0000000
--- a/primer/11/easyMath.py
+++ /dev/null
@@ -1,40 +0,0 @@
-
-from operator import add,sub
-from random import randint,choice
-
-ops ={"+":add,"-":sub}
-MAXTRIES = 2
-
-def doprob():
- op = choice('+-')
- nums = [randint(1,10) for i in range(2)]
- nums.sort(reverse = True)
- ans = ops[op](*nums)
- pr="%d %s %d =" %(nums[0],op,nums[1])
- oops =0
- while True:
- try:
- if int(raw_input(pr)) == ans:
- print "corrent"
- break
- if oops == MAXTRIES:
- print "answer \n %s%d" %(pr,ans)
- else:
- print "incorrent...try again"
- oops += 1
- except (KeyboardInterrupt, EOFError,ValueError):
- print "invalid input ... try again"
-
-def main():
- while True:
- doprob()
- try:
- opt= raw_input("Again?[y]".lower())
- if opt and opt[0] == "n":
- break
- except (KeyboardInterrupt,EOFError):
- break
-if __name__ == "__main__":
- main()
-
-
diff --git a/primer/11/grabWeb.py b/primer/11/grabWeb.py
deleted file mode 100644
index 5b3de06..0000000
--- a/primer/11/grabWeb.py
+++ /dev/null
@@ -1,26 +0,0 @@
-
-from urllib import urlretrieve
-
-def firstNoBlank(lines):
- for eachLine in lines:
- if not eachLine.strip():
- continue
- else:
- return eachLine
-
-def firstLast(webpage):
- f = open(webpage)
- lines= f.readlines()
- f.close()
- print firstNoBlank(lines),lines.reverse()
- print firstNoBlank(lines),
-
-def download(url = "http://www.cqupt.edu.cn",process=firstLast):
- try:
- retval = urlretrieve(url)[0]
- except IOError:
- retval = None
- if retval:
- process(retval)
-if __name__ == "__main__":
- download()
diff --git a/primer/11/numconv.py b/primer/11/numconv.py
deleted file mode 100644
index 63eb282..0000000
--- a/primer/11/numconv.py
+++ /dev/null
@@ -1,8 +0,0 @@
-
-def convert(func,seq):
- return[func (eachNum ) for eachNum in seq]
-
-myseq=(123,45.67,-6.2e8,99999999L)
-print convert(int,myseq)
-print convert(long,myseq)
-print convert(float,myseq)
diff --git a/primer/11/odd.py b/primer/11/odd.py
deleted file mode 100644
index 2a37d6a..0000000
--- a/primer/11/odd.py
+++ /dev/null
@@ -1,10 +0,0 @@
-
-from random import randint
-
-#def odd(n):
-# return n%2
-
-allNums =[]
-for eachNum in range(9):
- allNums.append(randint(1,99))
-print[n for n in allNums if n%2]
diff --git a/primer/11/testit.py b/primer/11/testit.py
deleted file mode 100644
index ad5037e..0000000
--- a/primer/11/testit.py
+++ /dev/null
@@ -1,26 +0,0 @@
-
-def testit(func,*nkwargs,**kwargs):
- try:
- retval = func(*nkwargs,**kwargs)
- result = (True,retval)
- except Exception,diag:
- result = (False,str(diag))
- return result
-
-def test():
- funcs =(int,long,float)
- vals = (1234,12.34,"1234","12.34")
-
- for eachFunc in funcs:
- print "_"*20
- for eachVal in vals:
- retval = testit(eachFunc,eachVal)
- if retval[0]:
- print "%s(%s)=" % \
- (eachFunc.__name__,"eachVal"),retval[1]
- else:
- print "%s(%s)=FAILED:" %\
- (eachFunc.__name__,"eachVal"),retval[1]
-
-if __name__ == "__main__":
- test()
diff --git a/primer/12/hot.py b/primer/12/hot.py
deleted file mode 100644
index e695791..0000000
--- a/primer/12/hot.py
+++ /dev/null
@@ -1,10 +0,0 @@
-class HotelRoomCalc(object):
- 'hotel room rate calculator'
- def __init__(self,rt,sales=0.085,rm=0.1):
- self.salesTax = sales
- self.roomTax = rm
- self.roomRate = rt
-
- def calcTotal(self,days = 1):
- daily = round((self.roomRate *(1+self.roomTax + self.salesTax)),2)
- return float(days)*daily
diff --git a/primer/13/NumStr.py b/primer/13/NumStr.py
deleted file mode 100644
index 986062b..0000000
--- a/primer/13/NumStr.py
+++ /dev/null
@@ -1,27 +0,0 @@
-class NumStr(object):
- def __init__(self,num=0,string=''):
- self.__num = num
- self.__string = string
-
- def __str__(self):
- return "[%d :: %r]" % (self.__num,self.__string)
- __repr__ = __str__
-
- def __add__(self,other):
- if isinstance(other,NumStr):
- return self.__class__(self.__num + \
- other.__num,self.__string+other.__string)
- else:
- return TypeError,"type error"
- def __mul__(self,num):
- if isinstance(num,int):
- return self.__class__(self.__num *num,self.__string *num)
- else:
- raise TypeError,"__num__ error"
- def __nonzero__(self):
- return self.__num or len(self.__string)
- def __norm_cval(self,cmpres):
- return cmp(cmpres,0)
- def __cmp__(self,other):
- return self.__norm_cval(cmp(self.__num,other.__num)) + \
- self.__norm_cval(cmp(self.__string,other.__string))
diff --git a/primer/13/Rand.py b/primer/13/Rand.py
deleted file mode 100644
index 1b56d0d..0000000
--- a/primer/13/Rand.py
+++ /dev/null
@@ -1,10 +0,0 @@
-
-from random import choice
-
-class Rand(object):
- def _init_(self,seq):
- self.data = seq
- def _iter_(self):
- return self
- def next(self):
- return choice(self.data)
diff --git a/primer/13/file.py b/primer/13/file.py
deleted file mode 100644
index 8830909..0000000
--- a/primer/13/file.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import os
-import pickle
-
-class File(object):
- saved=[]
- def __init__(self,name=None):
- self.name = name
- def __get__(self,obj,typ=None):
- if self.name not in File.saved:
- raise AttributeError,"%r used before assignment " % self.name
- try:
- f = open(self.name,"r")
- val = pickle.load(f)
- f.close()
- return val
- except (pickle.UnpicklingError,IOError,EOFError,AttributeError,\
- ImportError,IndexError),e:
- raise AttributeError,"could not read %r:%s" % (self.name,e)
- def __set__(self,obj,val):
- f = open(self.name,"w")
- try:
- pickle.dump(val,f)
- File.saved.append(self.name)
- except (TypeError,pickle.PicklingError),e:
- raise AttributeError,"could not pickle %r " % self.name
- finally:
- f.close()
-
- def __delete__(self,obj):
- try:
- os.unlink(self.name)
- File.saved.remove(self.name)
- except (OSError,ValueError),e:
- pass
diff --git a/primer/13/meta.py b/primer/13/meta.py
deleted file mode 100644
index 243a253..0000000
--- a/primer/13/meta.py
+++ /dev/null
@@ -1,28 +0,0 @@
-from warnings import warn
-
-class ReqStr(type):
- def __init__(cls,name,bases,attrd):
- super(ReqStr,cls).__init__(name,bases,attrd)
- if "__str__" not in attrd:
- raise TypeError("class overring __str__")
- if "__repr__" not in attrd:
- warn("class suggests __repr__",stacklevel = 3)
-print "define ReqStr (meta)class \n"
-
-class Foo(object):
- __metaclass__ = ReqStr
-
- def __str__(self):
- return "instance of class",self.__class__.__name__
-print "defined Foo class\n"
-
-class Bar(object):
- __metaclass__ = ReqStr
-
- def __str__(self):
- return self.__class__.__name__
-print "defined Bar class\n "
-
-class FooBar(object):
- __metaclass__ = ReqStr
-print "defined FooBar class \n"
diff --git a/primer/13/roundFloat.py b/primer/13/roundFloat.py
deleted file mode 100644
index 06cf9bf..0000000
--- a/primer/13/roundFloat.py
+++ /dev/null
@@ -1,9 +0,0 @@
-class RoundFloat(object):
- def __init__(self,val):
- assert isinstance(val,float),"Value must be a float"
- self.value = round(val,2)
-
- def __str__(self):
- return "%.2f" %self.value
- __repr__ = __str__
-
diff --git a/primer/13/time.py b/primer/13/time.py
deleted file mode 100644
index de514b5..0000000
--- a/primer/13/time.py
+++ /dev/null
@@ -1,28 +0,0 @@
-
-from time import time,ctime
-
-class Time(object):
- def __init__(self,obj):
- self.__data = obj;
- self.__ctime = self.__mtime =self.__atime=time()
- def get(self):
- self.__atime = time()
- return self.__data
- def gettimeval(self,t_type):
- if not isinstance(t_type,str) or t_type[0] not in "cma":
- raise TypeError," arg c m a"
- return getattr(self,"_%s__%stime" % (self.__class__.__name__,t_type[0]))
- def gettimestr(self,t_type):
- return ctime(self.gettimeval(t_type))
- def set(self,obj):
- self.__data = obj;
- self.__mtime = self.__atime= time()
- def __repr__(self):
- self.__atime = time()
- return 'self.__data'
- def __str__(self):
- self.__atime = time()
- return str(self.__data)
- def __getatt__(self,attr):
- self.__atime = time()
- return getattr(self.__data,attr)
diff --git a/primer/13/time60.py b/primer/13/time60.py
deleted file mode 100644
index a61ca1e..0000000
--- a/primer/13/time60.py
+++ /dev/null
@@ -1,14 +0,0 @@
-class Time60(object):
- def __init__(self,hr,min):
- self.hr = hr
- self.min = min
- def __str__(self):
- return "%d:%d" %(self.hr,self.min)
- __repr__ = __str__
-
- def __add__(self,other):
- return self.__class__(self.hr + other.hr,self.min+other.min)
- def __iadd__(self,other):
- self.hr += other.hr
- self.min += other.min
- return self
diff --git a/primer/16/sockCli.py b/primer/16/sockCli.py
deleted file mode 100644
index f97acee..0000000
--- a/primer/16/sockCli.py
+++ /dev/null
@@ -1,20 +0,0 @@
-from socket import *
-
-HOST ="localhost"
-PORT = 8888
-BUFSIZ = 1024
-ADDR = (HOST,PORT)
-
-while True:
- tcpCliSock = socket(AF_INET,SOCK_STREAM)
- tcpCliSock.connect(ADDR)
- data=raw_input(">")
-
- if not data:
- break
- tcpCliSock.send("%s\r\n" % data)
- data = tcpCliSock.recv(BUFSIZ)
- if not data:
- break
- print data.strip()
- tcpCliSock.close()
diff --git a/primer/16/sockServ.py b/primer/16/sockServ.py
deleted file mode 100644
index 9e4e38f..0000000
--- a/primer/16/sockServ.py
+++ /dev/null
@@ -1,17 +0,0 @@
-from SocketServer import (TCPServer as TCP,
- StreamRequestHandler as SRH)
-from time import ctime
-
-HOST=''
-PORT=8888
-ADDR=(HOST,PORT)
-
-class MyRequestHandler(SRH):
- def handle(self):
- print "......connected from :",self.client_address
- self.wfile.write('[%s] %s' %
- (ctime(),self.rfile.readline()))
-
-tcpSer = TCP(ADDR,MyRequestHandler)
-print "waiting for connection..."
-tcpSer.serve_forever()
diff --git a/primer/16/tcpclient.py b/primer/16/tcpclient.py
deleted file mode 100644
index b346fc6..0000000
--- a/primer/16/tcpclient.py
+++ /dev/null
@@ -1,21 +0,0 @@
-from socket import *
-
-HOST = "localhost"
-PORT = 21567
-BUFSIZ = 1024
-ADDR=(HOST,PORT)
-
-tcpCliSock = socket(AF_INET,SOCK_STREAM)
-tcpCliSock.connect(ADDR)
-
-while True:
- data = raw_input(">")
- if not data:
- break
- tcpCliSock.send(data)
- data = tcpCliSock.recv(BUFSIZ)
- if not data:
- break
- print data
-
-tcpCliSock.close()
diff --git a/primer/16/tcpserver.py b/primer/16/tcpserver.py
deleted file mode 100644
index 688b0aa..0000000
--- a/primer/16/tcpserver.py
+++ /dev/null
@@ -1,26 +0,0 @@
-
-from socket import *
-from time import ctime
-
-HOST =''
-PORT=21567
-BUFSIZ = 1024
-ADDR =(HOST,PORT)
-
-tcpSerSock = socket(AF_INET,SOCK_STREAM)
-tcpSerSock.bind(ADDR)
-tcpSerSock.listen(5)
-
-while True:
- print "waiting from connection..."
- tcpCliSock,addr = tcpSerSock.accept()
- print "...connected from :",addr
-
- while True:
- data = tcpCliSock.recv(BUFSIZ)
- if not data:
- break
- tcpCliSock.send('[%s] %s' %(ctime(),data))
-
- tcpCliSock.close()
-tcpSerSock.close()
diff --git a/primer/16/udpCli.py b/primer/16/udpCli.py
deleted file mode 100644
index 9a502f3..0000000
--- a/primer/16/udpCli.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from socket import *
-
-HOST="localhost"
-PORT=21567
-BUFSIZ = 1024
-ADDR= (HOST,PORT)
-
-udpCliSock= socket(AF_INET,SOCK_DGRAM)
-
-while True:
- data = raw_input(">")
- if not data:
- break
- udpCliSock.sendto(data,ADDR)
- data,ADDR= udpCliSock.recvfrom(BUFSIZ)
- if not data:
- break
- print data
-udpCliSock.close()
diff --git a/primer/16/udpSer.py b/primer/16/udpSer.py
deleted file mode 100644
index bf7eabb..0000000
--- a/primer/16/udpSer.py
+++ /dev/null
@@ -1,17 +0,0 @@
-from socket import *
-from time import ctime
-
-HOST =''
-PORT=21567
-BUFSIZ=1024
-ADDR =(HOST,PORT)
-
-udpSerSock = socket(AF_INET,SOCK_DGRAM)
-udpSerSock.bind(ADDR)
-
-while True:
- print "waiting for message..."
- data,addr = udpSerSock.recvfrom(BUFSIZ)
- udpSerSock.sendto('[%s] %s' %(ctime(),data),addr)
- print "...received from and returned to :",addr
-udpSerSock.close()
diff --git a/primer/18/sleep.py b/primer/18/sleep.py
deleted file mode 100644
index 65c80cd..0000000
--- a/primer/18/sleep.py
+++ /dev/null
@@ -1,26 +0,0 @@
-from time import sleep,ctime
-import thread
-
-loops =[4,2,11]
-def loop(nloop,nsec,lock):
- print " start loop:",nloop,"at",ctime()
- sleep(nsec)
- print "loop :",nloop, "done at:",ctime()
-
-def main():
- print "start at:", ctime()
- locks = []
- nloops = range(len(loops))
-
- for i in nloops:
- lock = thread.allocate_lock()
- lock.acquire()
- locks.append(lock)
- for i in nloops:
- thread.start_new_thread(loop,(i,loops[i],locks[i]))
- for i in nloops:
- while locks[i].locked():pass
-
- print " all done at:" ,ctime()
-if __name__ == "__main__":
- main()
diff --git a/primer/18/threading.py b/primer/18/threading.py
deleted file mode 100644
index 367fcf3..0000000
--- a/primer/18/threading.py
+++ /dev/null
@@ -1,37 +0,0 @@
-import threading
-from time import sleep,ctime
-
-loops = [4,2]
-
-class ThreadFunc(object):
- def __init__(self,func,args,name=""):
- self.name = name
- self.name = func
- self.args = args
- def __call__(self):
- apply(self.func,slef.args)
-
- def loop(nloop,nsec):
- print "start loop:",nloop,"at:",ctime()
- sleep(nsec)
- print "loop",nloop,"done at:",ctime()
-
- def main():
- print "starting at:",ctime()
- threads = []
- nloops = range(len(loops))
- #创建线程
- for i in nloops:
- t = threading.Thread(target = loop,args=(i,loops[i]))
- threads.append(t);
- #启动线程
- for i in nloops:
- threads[i].start()
- #等待线程
- for i in nloops:
- threads[i].join()
- print "all DONE at:",ctime()
-
-if __name__ == "__main__":
- main()
-
diff --git a/primer/19/label.py b/primer/19/label.py
deleted file mode 100644
index cec761f..0000000
--- a/primer/19/label.py
+++ /dev/null
@@ -1,11 +0,0 @@
-import Tkinter
-
-top = Tkinter.Tk()
-
-label = Tkinter.Label(top,text="input")
-label.pack()
-
-button = Tkinter.Button(top,text="QIUT",command=top.quit,bg="red",fg="white")
-button.pack(fill=Tkinter.X,expand=1)
-
-Tkinter.mainloop()
diff --git a/primer/2/2_10.py b/primer/2/2_10.py
deleted file mode 100644
index d2dec79..0000000
--- a/primer/2/2_10.py
+++ /dev/null
@@ -1,10 +0,0 @@
-a = 19
-print "please input a int number in 1-100"
-x = raw_input()
-while x != a:
- print "sorry error: \n input again:"
- x = raw_input()
-if x == a:
- print "you are right"
- break
-raw_input()
diff --git a/primer/2/2_11.py b/primer/2/2_11.py
deleted file mode 100644
index 5c3877d..0000000
--- a/primer/2/2_11.py
+++ /dev/null
@@ -1,25 +0,0 @@
-print "Menu: input the choice\n"
-print "s: sum"
-print "a: avg"
-print "x: exit"
-aa =[1,2,3,4]
-while True:
- ch = raw_input()
- if ch == 's':
- i = 0
- Sum = 0
- print "you choice sum:\n"
- for i in aa:
- Sum += i
- print Sum
- if ch == 'a':
- print "you choice avg:\n"
- i = 0
- Sum1 = 0
- for i in aa:
- Sum1 += i
- avg = float(Sum1)/(len(aa))
- print avg
- if ch == 'x':
- break
-
diff --git a/primer/2/2_2.py b/primer/2/2_2.py
deleted file mode 100644
index 5d71d06..0000000
--- a/primer/2/2_2.py
+++ /dev/null
@@ -1,9 +0,0 @@
-a = '19'
-print "please input a int number in 1-100"
-x = raw_input()
-if a != x:
- print "sorry you are wrong!\ninput again:"
- x = raw_input()
-else
- print "you are right"
-raw_input()
diff --git a/primer/2/2_7.py b/primer/2/2_7.py
deleted file mode 100644
index 8405c4b..0000000
--- a/primer/2/2_7.py
+++ /dev/null
@@ -1,5 +0,0 @@
-s = raw_input()
-i = 0
-for i in s:
- print i
-raw_input()
diff --git a/primer/2/2_8.py b/primer/2/2_8.py
deleted file mode 100644
index 7ea33df..0000000
--- a/primer/2/2_8.py
+++ /dev/null
@@ -1,7 +0,0 @@
-s=[1,2,3,4,5,6]
-i = 0
-t = 0
-for i in s:
- t += i
-print float(t)/len(s)
-raw_input()
diff --git a/primer/20/Cralwer.py b/primer/20/Cralwer.py
deleted file mode 100644
index 3afa5d2..0000000
--- a/primer/20/Cralwer.py
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/env python
-
-from sys import argv
-from os import makedirs,unlink,sep
-from os.path import dirname,exists,isdir,splitext
-from string import replace,find,lower
-from htmllib import HTMLParser
-from urllib import urlretrieve
-from urlparse import urlparse,urljoin
-from formatter import DumbWriter,AbstractFormatter
-from cStringIO import StringIO
-
-class Retriever(object):#下载网页类
-
- def __init__(self,url):
- self.url = url
- self.file = self.filename(url)
-
- def filename(self,url,deffile ="index.htm"):
- parsedurl = urlparse(url,"http:",0) #解析路径
- path = parsedurl[1] + parsedurl[2]
- ext = splitext(path)
- if ext[1] == "": #如果没有文件,使用默认
- if path[-1] == "/":
- path += deffile
- else:
- path += "/" + deffile
- ldir = dirname(path) #本地目录
- if sep != "/":
- ldir = replace(ldir,"/",sep)
- if not isdir(ldir): #如果没有目录,创建一个
- if exists(ldir):unlink(ldir)
- makedirs(ldir)
- return path
-
- def download(self):# 下载网页
- try:
- retval = urlretrieve(self.url,self.file)
- except IOError:
- retval = ('***Error: invalid URL: "%s"' % self.url,)
- return retval
-
- def parseAndGetLinks(self): #解析HTML,保存链接
- self.parser = HTMLParser(AbstractFormatter(DumbWriter(StringIO())))
- self.parser.feed(open(self.file).read())
- self.parser.close()
- return self.parser.anchorlist
-
-
-class Crawler(object): #管理类,管理整个爬行过程
-
- count = 0 #下载网页计数器
-
- def __init__ (self,url):
- self.q = [url] #链接队列
- self.seen = [] #已下载
- self.dom = urlparse(url)[1] #判断链接是否为主链接的子域名
-
- def getPage(self,url): #下载网页
- r = Retriever(url)
- retval = r.download()
- if retval[0] == "*": #错误,不解析
- print retval,"--- skipping parse"
- return
- Crawler.count += 1
- print '\n(',Crawler.count,')'
- print "URL:",url
- print "FILE:",retval[0]
- self.seen.append(url)
-
- links = r.parseAndGetLinks() #得到链接
- for eachLink in links:
- if eachLink[:4] != "http" and find(eachLink,"://") == -1:
- eachLink = urljoin(url,eachLink)
- print "* ",eachLink
-
- if find(lower(eachLink),"mailto:") != -1: #过滤邮箱链接
- print "--- discarded,mailto link"
- continue
-
- if eachLink not in self.seen:
- if find(eachLink,self.dom) == -1:
- print "---discarded,not in domain"
- else:
- if eachLink not in self.q:
- self.q.append(eachLink)
- print "---new,add to Q"
- else:
- print "---discarded,already in Q"
- else:
- print "---discarded, arlready processed"
-
- def go(self): #在队列里处理链接,启动
- while self.q:
- url=self.q.pop()
- self.getPage(url)
-
-def main():
- if len(argv) > 1:
- url = argv[1]
-
- else:
- try:
- url = raw_input("Enter starting URL:")
- except (KeyboardInterrupt,EOFError):
- url = ""
-
- if not url: return
- robot = Crawler(url)
- robot.go()
-
-if __name__ == "__main__":
- main()
-
diff --git a/primer/3/makeFile.py b/primer/3/makeFile.py
deleted file mode 100644
index bee369a..0000000
--- a/primer/3/makeFile.py
+++ /dev/null
@@ -1,14 +0,0 @@
-import os
-
-filename=raw_input("filename:")
-if os.path.exists(filename):
- print "file exist"
- exit()
-
-
-fd=open(filename,'r')
-fd.writelines(all)
-fd.close()
-
-print "done"
-
diff --git a/primer/3/makeTextFile.py b/primer/3/makeTextFile.py
deleted file mode 100644
index 6969f8f..0000000
--- a/primer/3/makeTextFile.py
+++ /dev/null
@@ -1,32 +0,0 @@
-
-'makeTextFile.py -- create text file'
-
-import os
-ls = os.linesep
-
-#get filename
-while True:
- fname = raw_input()
- if os.path.exists(fname):
- print "ERROR: '%s' already exists " %fname
- else:
- break
-
-#get file content lines
-all = []
-print "\n Enter lines:('.' by itself to quit)\n"
-
-#loop until user terminates input
-while True:
- entry = raw_input('>')
- if entry == '.':
- break
- else:
- all.append(entry)
-
-#write lines to file with proper line-ending
-fobj = open(fname,'w')
-fobj.writelines(['%s%s' %(x,ls) for x in all])
-fobj.close()
-print 'DONE!'
-
diff --git a/primer/3/readTextFile.py b/primer/3/readTextFile.py
deleted file mode 100644
index 980d3e0..0000000
--- a/primer/3/readTextFile.py
+++ /dev/null
@@ -1,17 +0,0 @@
-
-'readTextFile.py -- read and display text file'
-
-#get filename
-fname = raw_input("enter the filename:")
-print
-
-#attempt to open file for reading
-try:
- fobj = open(fname,'r')
-except IOError,e:
- print "*** file open error",e
-else:
- #display contents to the screen
- for echoLine in fobj:
- print echoLine;
-fobj.close()
diff --git a/primer/4/display.py b/primer/4/display.py
deleted file mode 100644
index e50f368..0000000
--- a/primer/4/display.py
+++ /dev/null
@@ -1,11 +0,0 @@
-def displayType(num):
- print num, 'is',
- if isinstance(num,(int,long,float,complex)):
- print "a number of type:",type(num).__name__
- else:
- print "not a number at all"
-
-displayType(2)
-displayType(-1.9)
-displayType(-1+1.9j)
-displayType('xcxx')
diff --git a/primer/6/idcheck.py b/primer/6/idcheck.py
deleted file mode 100644
index b6d6220..0000000
--- a/primer/6/idcheck.py
+++ /dev/null
@@ -1,20 +0,0 @@
-import string
-
-alphas = string.letters +'_'
-nums = string.digits
-
-print "Welcom to the indetifter Checker V1.0"
-print "Test must be at least 2 Chars long"
-myinput = raw_input("Iddentifter to test:\n")
-
-if len(myinput) > 1:
- if myinput[0] not in alphas:
- print "invald: first symbol must be alphbetic"
- else:
- for otherChar in myinput[1:]:
- if alphas not in alphas + nums:
- print "invalid:remaining symbols must be alphanumeric"
- break
- else:
- print "ok as an identifier"
-raw_input()
diff --git a/primer/6/queue.py b/primer/6/queue.py
deleted file mode 100644
index 7eb364d..0000000
--- a/primer/6/queue.py
+++ /dev/null
@@ -1,38 +0,0 @@
-
-queue = []
-def enQ():
- queue.append(raw_input("enter new string:").strip())
-def deQ():
- if len(queue) == 0:
- print "empty queue\n"
- else:
- print 'Removed![',`queue.pop()`,']'
-def viewQ():
- print queue
-
-CMDS = {'e': enQ,'d':deQ,'v':viewQ}
-def showmenu():
- pr="""
-(E)nqueue
-(D)enqueue
-(V)iew
-(Q)uit
-
- enter choice: """
- while True:
- while True:
- try:
- choice = raw_input(pr).strip()[0].lower()
- except (EOFError,KeyboardInterpt,IndexError):
- choice = "q"
- print "\nYou picked:[%s]" % choice
- if choice not in "devq":
- print "error,try again"
- else:
- break
- if choice == "q":
- break
- CMDS[choice]()
-if __name__ == '__main__':
- showmenu()
-
diff --git a/primer/6/stack.py b/primer/6/stack.py
deleted file mode 100644
index 60dc053..0000000
--- a/primer/6/stack.py
+++ /dev/null
@@ -1,43 +0,0 @@
-stack = []
-
-def pushit():
- stack.append(raw_input("enter a string:").strip())
-
-def popit():
- if len(stack) == 0:
- print "stack is empty!\n"
- else:
- print 'Removed![',`stack.pop()`,']'
-
-def viewstack():
- print stack
-
-CMDS ={'u': pushit,'o':popit,'v':viewstack}
-
-def showmenu():
- pr = """
- p(U)sh
- p(O)p
- (V)iew
- (Q)uit
-
- enter the choice: """
- while True:
- while True:
- try:
- choice = raw_input(pr).strip()[0].lower()
- except (EOFError,KeyboardInterrupt,IndexError):
- choice ="q"
-
- print "\nYou picked:[%s]" % choice
- if choice not in "uovq":
- print "Invalid option,try again"
- else:
- break
-
- if choice == "q":
- break
- CMDS[choice]()
-if __name__ == "__main__":
- showmenu()
-
diff --git a/primer/6/unicode.txt b/primer/6/unicode.txt
deleted file mode 100644
index f3e8683..0000000
--- a/primer/6/unicode.txt
+++ /dev/null
@@ -1 +0,0 @@
-hhhh
diff --git a/primer/6/unicodeFile.py b/primer/6/unicodeFile.py
deleted file mode 100644
index 0752725..0000000
--- a/primer/6/unicodeFile.py
+++ /dev/null
@@ -1,20 +0,0 @@
-'''
-An example for unicode string
-'''
-
-CODEC = "utf-8"
-FILE = "unicode.txt"
-
-hello = u"hhhh\n"
-byte = hello.encode(CODEC)
-f = open(FILE,"w")
-f.write(byte)
-f.close()
-
-f = open(FILE,"r")
-byte = f.read()
-f.close()
-
-hello = byte.decode(CODEC)
-print hello
-raw_input()
diff --git a/primer/7/userpw.py b/primer/7/userpw.py
deleted file mode 100644
index ebe358e..0000000
--- a/primer/7/userpw.py
+++ /dev/null
@@ -1,53 +0,0 @@
-db = {}
-
-def newuser():
- prompt = "login desired:"
- while True:
- name = raw_input(prompt)
- if db.has_key(name):
- prompt = "name taken,try again: "
- continue
- else:
- break
- pwd = raw_input("passwd:")
- db[name]= pwd
- print "regeisted oK!\n"
-
-def olduser():
- name = raw_input("login:")
- pwd = raw_input("passwd:")
- passwd = db.get(name)
- if passwd == pwd:
- print "welcome back," ,name
- else:
- print "login incorrect"
-
-def showmenu():
- prompt = """
- (n) new user login
- (l) exiting user login
- (q) quit
- enter choice : """
-
- done = False
- while not done:
- chosen = False
- while not chosen:
- try:
- choice = raw_input(prompt).strip()[0].lower()
- except(EOFError,KeyboardInterrupt):
- choice = "q"
- print "\n you picked [%s]" % choice
- if choice not in "nlq":
- print "invalid option, try again"
- else:
- chosen = True
-
- if choice == "q": done = True
- if choice == "n": newuser()
- if choice == "l": olduser()
-
-if __name__ == "__main__":
- showmenu()
-
-
diff --git a/primer/9/ospathex.py b/primer/9/ospathex.py
deleted file mode 100644
index a333211..0000000
--- a/primer/9/ospathex.py
+++ /dev/null
@@ -1,38 +0,0 @@
-
-import os
-for tmpdir in("/tmp"):
- if os.path.isdir(tmpdir):
- break
- else:
- print "no temp dir available"
- tmpdir = ""
-if tmpdir:
- os.chdir(tmpdir)
- cwd = os.getcwd()
- print " current tmp dir"
- print cwd
-
- print "create example dir"
- os.mkdir("example")
- os.chdir("example")
- cwd = os.getcwd()
- print "new work dir"
- print cwd
- print "list the dir"
- print os.listdir(cwd)
-
- print "create test file"
- fobj = open("test","w")
- fobj.write("xxg\n")
- fobj.write("111111")
- fobj.close()
-
- print "update the list dir"
- print os.listdir(cwd)
-
- print "rename the file"
- os.rename("test","xxg.txt")
- print os.listdir(cwd)
-
-
-
diff --git a/unp/1/download.py b/unp/1/download.py
deleted file mode 100644
index 253caf1..0000000
--- a/unp/1/download.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env python
-
-import urllib,sys
-
-f=urllib.urlopen(sys.argv[1])
-
-while True:
- buf = f.read(2048)
- if not len(buf):
- break
- sys.stdout.write(buf)
diff --git a/unp/1/gopherclient.py b/unp/1/gopherclient.py
deleted file mode 100644
index d5c01ce..0000000
--- a/unp/1/gopherclient.py
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env python
-# --coding: utf-8 --
-#简单的Gopher Client
-
-import socket,sys
-
-port = 70 #默认端口 70
-host = sys.argv[1]
-filename = sys.argv[2]
-
-s= socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-s.connect((host,port))
-
-s.sendall(filename + "\r\n")
-
-while 1:
- buf = s.recv(2048)
- if not len(buf):
- break
- sys.stdout.write(buf)
-
-
diff --git a/unp/1/gopherclient2.py b/unp/1/gopherclient2.py
deleted file mode 100644
index 5b1b954..0000000
--- a/unp/1/gopherclient2.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-# --coding: utf-8 --
-#简单的Gopher Client
-
-import socket,sys
-
-port = 70 #默认端口 70
-host = sys.argv[1]
-filename = sys.argv[2]
-
-s= socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-
-try:
- s.connect((host,port))
-except socket.gaierror,e:
- print "Error connecting to server:%s" % e
- sys.exit(1)
-
-s.sendall(filename + "\r\n")
-
-while 1:
- buf = s.recv(2048)
- if not len(buf):
- break
- sys.stdout.write(buf)
-
-
diff --git a/unp/1/gopherclient3.py b/unp/1/gopherclient3.py
deleted file mode 100644
index 4bd6831..0000000
--- a/unp/1/gopherclient3.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-# --coding: utf-8 --
-#简单的Gopher Client
-
-import socket,sys
-
-port = 70 #默认端口 70
-host = sys.argv[1]
-filename = sys.argv[2]
-
-s= socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-s.connect((host,port))
-
-fd = s.makefile('rw',0)
-
-fd.write(filename + "\r\n")
-
-for line in fd.readline():
- sys.stdout.write(line)
-
-
-
-
-
-
-
-
diff --git a/unp/1/server.py b/unp/1/server.py
deleted file mode 100644
index ca441c7..0000000
--- a/unp/1/server.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#! /usr/bin env python
-
-import socket
-
-host=''
-porr=51423
-
-s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
-s.bind((host,porr))
-s.listen(1)
-
-print "server is runing on port %d" % port
-
-while 1:
- clientsock,clientaddr=s.accept()
- clientfile=clientsock.makefile('rw',0)
- clientfile.write("welcome," + str(clientaddr) + "\n")
- clientfile.write("please enter a string:")
- line = clientfile.readline().strip()
- clientfile.write("you enter %d char" % len(line) )
- clientfile.close()
- clientsock.close()
-
-
diff --git a/unp/2/connect.py b/unp/2/connect.py
deleted file mode 100644
index 2938a35..0000000
--- a/unp/2/connect.py
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin env python
-
-import socket
-
-print "create socket"
-s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-print "done"
-
-
-print "connecting to the host"
-s.connect(('localhost',8888))
-print "done"
diff --git a/unp/2/connect1.py b/unp/2/connect1.py
deleted file mode 100644
index f1efdd4..0000000
--- a/unp/2/connect1.py
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin env python
-
-import socket
-
-print "create socket"
-s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-print "done"
-
-print "look up port number"
-port=socket.getservbyname('http','tcp')
-print "done"
-
-
-print "connecting to the host on port %d" % port
-s.connect(("www.baidu.com",port))
-print "done"
diff --git a/unp/2/connect3.py b/unp/2/connect3.py
deleted file mode 100644
index 559e5fa..0000000
--- a/unp/2/connect3.py
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin env python
-
-import socket
-
-print "create socket"
-s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-print "done"
-
-print "look up port number"
-port=socket.getservbyname('http','tcp')
-print "done"
-
-
-print "connecting to the host on port %d" % port
-s.connect(("www.baidu.com",port))
-print "done"
-
-print "connected from",s.getsockname()
-print "connected to",s.getpeername()
diff --git a/unp/2/socketerrors.py b/unp/2/socketerrors.py
deleted file mode 100644
index f7dc995..0000000
--- a/unp/2/socketerrors.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin env python
-
-import socket,sys
-
-host=sys.argv[1]
-textport=sys.argv[2]
-filename=sys.argv[3]
-
-try:
- s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-except socket.error,e:
- print "strange erroe create socket %s" % e
- sys.exit(1)
-
-
-try:
- port = int(textport)
-except ValueError:
- try:
- port=socket.getservbyname(textport,'tcp')
- except socket.error,e:
- print "could find you port %s" % e
- sys.exit(1)
-
diff --git a/unp/2/udp.py b/unp/2/udp.py
deleted file mode 100644
index 7c950e5..0000000
--- a/unp/2/udp.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#! /usr/bin env python
-
-import socket,sys
-
-host=sys.argv[1]
-textport=sys.argv[2]
-
-s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
-
-try:
- port=int(textport)
-except ValueError:
- port=socket.getservbyname(textport,'udp')
-
-
-s.connect((host,port))
-
-print "enter data to tranmit:"
-
-data=sys.stdin.readline().strip()
-s.sendall(data)
-
-print "looking for replies;"
-
-while 1:
- buf=s.recv(2048)
- if not len(buf):
- break
- sys.stdout.write(buf)
-
-
diff --git a/unp/3/basicserver.py b/unp/3/basicserver.py
deleted file mode 100644
index 1977ee0..0000000
--- a/unp/3/basicserver.py
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin env python
-
-import socket
-
-host=''
-port=8888
-
-s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
-s.bind((host,port))
-print "waiting for connect..."
-s.listen(1)
-
-while 1:
- clientsock,clientaddr=s.accept()
- print "Go connection from ,", clientsock.getpeername()
- clientsock.close()
-
diff --git a/unp/3/echoclient.py b/unp/3/echoclient.py
deleted file mode 100644
index 7b5e002..0000000
--- a/unp/3/echoclient.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin env python
-
-import sys,socket
-
-host='localhost'
-port=8888
-
-data="x"*1024
-
-s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-s.connect((host,port))
-
-bytewritten=0
-while bytewritten < len(data):
- startpos=bytewritten
- endpos=min(bytewritten + 1024,len(data))
- bytewritten += s.send(data[startpos:endpos])
- sys.stdout.write("write %d bytes\r" % bytewritten)
- sys.stdout.flush()
-
-s.shutdown(1)
-
-print "All data sent"
-while 1:
- buf=s.recv(1024)
- if not len(buf):
- break
- sys.stdout.write(buf)
-
-
diff --git a/unp/3/echoserver.py b/unp/3/echoserver.py
deleted file mode 100644
index 4e2a6ee..0000000
--- a/unp/3/echoserver.py
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin env python
-#!--coding: utf-8 --
-
-import socket,traceback
-
-host=''
-port=8888
-
-s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
-s.bind((host,port))
-s.listen(1)
-
-while 1:
- try:
- clientsock,clientaddr=s.accept()
- except KeyboardInterrupt:
- raise
- except:
- traceback.print_exc()
- continue
-
- try:
- print "Got connection from " ,clientsock.getpeername()
- while 1:
- data= clientsock.recv(4096)
- if not len(data):
- break
- clientsock.sendall(data)
- except (KeyboardInterrupt,SystemExit):
- raise
- except:
- traceback.print_exc()
- try:
- clientsock.close()
- except KeyboardInterrupt:
- raise
- except:
- traceback.print_exc()
-
-
-
-
-
diff --git a/unp/3/socketop.py b/unp/3/socketop.py
deleted file mode 100644
index 073e6dd..0000000
--- a/unp/3/socketop.py
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin env python
-
-import socket
-
-solist = [x for x in dir(socket) if x.startswith('SO_') ]
-solist.sort()
-
-for x in solist:
- print x
diff --git a/unp/3/syslogsample.py b/unp/3/syslogsample.py
deleted file mode 100644
index 6faf4a2..0000000
--- a/unp/3/syslogsample.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin env python
-#!--coding: utf-8--
-
-import syslog,StringIO,sys,os,traceback
-
-def logexception(includetraceback=0):
- exctype,exception,exctraceback=sys.exc_info()
- excclass=str(exception.__class__)
- message=str(exception)
-
- if not includetraceback:
- syslog.syslog(syslog.LOG_ERR,"%s: %s" % (excclass,message))
- else:
- excfd=StringIO.StringIO()
- traceback.print_exception(exctype,exception,exctraceback,None,excfd)
-
- for line in excfd.getvalue().split("\n"):
- syslog.syslog(syslog.LOG_ERR,line)
-
-def initsyslog():
- syslog.openlog("%s[%d]" % (os.path.basename(sys.argv[0]),os.getpid()),0,
- syslog.LOG_DAEMON)
- syslog.syslog("started.")
-
-
-initsyslog()
-try:
- raise RuntimeError, "Exception 1"
-except:
- logexception(0)
-
-try:
- raise RuntimeError, "Exception 2"
-except:
- logexception(1)
-
-syslog.syslog("I am a terimiting.")
-
-
-
diff --git a/unp/3/udpechoserver.py b/unp/3/udpechoserver.py
deleted file mode 100644
index dc6cdcb..0000000
--- a/unp/3/udpechoserver.py
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin env python
-
-import socket,traceback
-
-host=''
-port=8888
-
-s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
-s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
-s.bind((host,port))
-
-while 1:
- try:
- message,address=s.recvfrom(8192)
- print "Go data from",address
- s.sendall(message,address)
- except (keyboardInterrupt,SystemExit):
- raise
- except:
- traceback.print_exc()
-
-
diff --git a/unp/3/xinetdserver.py b/unp/3/xinetdserver.py
deleted file mode 100644
index 492b0cb..0000000
--- a/unp/3/xinetdserver.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#/usr/bin env python
-
-import sys
-print "welcome...."
-print "please enter a string:"
-
-sys.stdout.flush()
-line=sys.stdin.readline().strip()
-
-
-print "you enter the %s is %d count" % (line,len(line))
diff --git a/unp/4/dns.py b/unp/4/dns.py
deleted file mode 100644
index 5923b53..0000000
--- a/unp/4/dns.py
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin env python
-
-import sys,DNS
-
-query=sys.argv[1]
-DNS.DiscoverNameServers()
-
-reqobj=DNS.Request()
-
-answerobj=reqobj.req(name=query,qtype=DNS.Type.ANY)
-if not len(answerobj.answers):
- print "not find"
-for i in answerobj.answers:
- print "%-5s %s " % (i['typename'],i['data'])
-
diff --git a/unp/4/dns.pyc b/unp/4/dns.pyc
deleted file mode 100644
index a54fc76..0000000
Binary files a/unp/4/dns.pyc and /dev/null differ
diff --git a/unp/4/environment.py b/unp/4/environment.py
deleted file mode 100644
index e29251f..0000000
--- a/unp/4/environment.py
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin env pythhon
-
-import sys,socket
-
-def getipaddrs(hostname):
- s=socket.getaddrinfo(hostname,None,0,socket.SOCK_STREAM)
- return [x[4][0] for x in s]
-
-hostname=socket.gethostname()
-print "Host name:",hostname
-
-print "full-name:",socket.getfqdn(hostname)
-try:
- print "IP address:",", ".join(getipaddrs(hostname))
-except socket.gaierror,e:
- print "can not get ip address",e
-
diff --git a/unp/4/getaddrinfo.py b/unp/4/getaddrinfo.py
deleted file mode 100644
index 5d01ae6..0000000
--- a/unp/4/getaddrinfo.py
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin env python
-
-import socket,sys
-
-s=socket.getaddrinfo(sys.argv[1],None,0,socket.SOCK_STREAM)
-
-counter=0
-for i in s:
- print "%d %s" % (counter,s[counter][4])
- counter += 1
-
-
diff --git a/unp/4/gethostbyaddr.py b/unp/4/gethostbyaddr.py
deleted file mode 100644
index 4eb61c5..0000000
--- a/unp/4/gethostbyaddr.py
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin env python
-
-import sys,socket
-
-try:
-
- s=socket.gethostbyaddr(sys.argv[1])
-
- print "hostname:"
- print " "+ s[0]
-
- print "\nAddress:"
- for i in s[2]:
- print " " + i
-
-except socket.herror,e:
- print "can not look up name:",e
-
-
diff --git a/unp/5/bcastclinet.py b/unp/5/bcastclinet.py
deleted file mode 100644
index 8ed2d3a..0000000
--- a/unp/5/bcastclinet.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin env python
-
-import socket,traceback
-
-host=''
-port=8888
-
-
-s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
-s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
-s.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1)
-s.bind((host,port))
-
-while 1:
- try:
- message,address=s.recvfrom(8192)
- print "Got data from",addrrss
- s.sendto("I am here",address)
- except (KeyboardInterrupt,SystemExit):
- raise
- except:
- traceback.print_exc()
-
-
-
diff --git a/unp/5/bcastserver.py b/unp/5/bcastserver.py
deleted file mode 100644
index 0332651..0000000
--- a/unp/5/bcastserver.py
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin env python
-
-import sys,socket
-
-dest=('',8888)
-
-s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
-s.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1)
-s.sendto("hello",dest)
-
-print "look for replies ...."
-while 1:
- (buf,address)=s.recvfrom(2048)
- if not len(buf):
- break
- print "Recived from %s: %s" % (address,buf)
diff --git a/unp/5/delayserver.py b/unp/5/delayserver.py
deleted file mode 100644
index 388d6f9..0000000
--- a/unp/5/delayserver.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin env python
-
-import socket,traceback,time
-
-host=''
-port=8888
-
-s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
-s.bind((host,port))
-
-s.listen(1)
-
-
-while 1:
- try:
- clientsock,clientaddr= s.accept()
- except KeyboardInterrupt:
- raise
- except:
- traceback.print_exc()
- continue
-
- try:
- print "get connect from",clientsock.getpeername()
- while 1:
- try:
- clientsock.sendall(time.asctime() + "\n")
- except:
- break
- time.sleep(5)
- except (KeyboardInterrupt,SystemExit):
- raise
- except:
- traceback.print_exc()
-try:
- clientsock.close()
-except KeyboardInterrupt:
- raise
-except:
- traceback.print_exc()
-
-try:
- clientsock.close()
-except KeyboardInterrupt:
- raise
-except:
- traceback.print_exc()
-
-
-
-
diff --git a/unp/5/nbo.py b/unp/5/nbo.py
deleted file mode 100644
index f82760b..0000000
--- a/unp/5/nbo.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin env python
-
-import struct,sys
-
-def htons(num):
- return struct.pack('!H',num)
-
-def htonl(num):
- return struct.pack('!I',num)
-
-def ntohs(data):
- return struct.unpack('!H',data)[0]
-
-def ntohl(data):
- return struct.unpack("!I",data)[0]
-
-def sendstring(data):
- return htonl(len(data)) + data
-
-print "Enter a string:"
-str=sys.stdin.readline().rstrip()
-
-print repr(sendstring(str))
diff --git a/unp/5/pollclient.py b/unp/5/pollclient.py
deleted file mode 100644
index 61c32b0..0000000
--- a/unp/5/pollclient.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin env python
-
-import socket,sys,select
-port=8888
-host='localhost'
-
-spinsize=10
-spinpos=0
-spindir=1
-
-def spin():
- global spinsize,spinpos,spindir
- spinstr='.' * spinpos + '|'+'.'(spinsize-spinpos-1)
- sys.stdout.write('r'+ spinstr + ' ')
- sys.stdout.flush()
-
- spinpos += spindir
- if spinpos < 0:
- spindir=1
- spinpos=1
- elif spinpos >= spinsize:
- spinpos -= 2
- spindir = -1
-
-s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-s.connect((host,port))
-
-p=select.poll()
-p.register(s.fileno(),select.POLLIN | select.POLLERR | select.POLLHUP)
-
-while 1:
- results=p.poll(50)
- if len(results):
- if results[0][1] == select.POLLIN:
- data = s.recv(4096)
- if not len(data):
- print "Remote end closed connect"
- break
- sys.stdout.write("\rReceived:" + data)
- sys.stdout.flush()
- else:
- print "\rproblem occurred ; exiting"
- sys.exit(0)
-
-spin()
-
-
diff --git a/unp/5/selectclient.py b/unp/5/selectclient.py
deleted file mode 100644
index 03cc94b..0000000
--- a/unp/5/selectclient.py
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin env python
-
-import socket,sys,select
-port=8888
-host='localhost'
-
-spinsize=10
-spinpos=0
-spindir=1
-
-def spin():
- global spinsize,spinpos,spindir
- spinstr='.' * spinpos + '|' +'.'*(spinsize-spinpos-1)
- sys.stdout.write('r'+ spinstr + ' ')
- sys.stdout.flush()
-
- spinpos += spindir
- if spinpos < 0:
- spindir=1
- spinpos=1
- elif spinpos >= spinsize:
- spinpos -= 2
- spindir = -1
-
-s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-s.connect((host,port))
-
-while 1:
- infds,outfds,errfds=select.select([s],[],[s],0.05)
- if len(infds):
- data=s.recv(4096)
- if not len(data):
- print "\rRemote end closed connection; exiting"
- break
-
- sys.stdout.write("\rRecived: " + data)
- sys.stdout.flush()
-
- if len(errfds):
- print "\r problem occurred; exiting"
- sys.exit(0)
-
-spin()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/unp/5/timeoutserver.py b/unp/5/timeoutserver.py
deleted file mode 100644
index 229476d..0000000
--- a/unp/5/timeoutserver.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin env python
-
-import socket,traceback
-
-host=''
-port=8888
-
-s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
-s.bind((host,port))
-
-s.listen(1)
-
-
-while 1:
- try:
- clientsock,clientaddr= s.accept()
- except KeyboardInterrupt:
- raise
- except:
- traceback.print_exc()
- continue
- clientsock.settimeout(5)
-
- try:
- print "get connect from",clientsock.getpeername()
- while 1:
- data=clientsock.recv(4096)
- if not len(data):
- break
- clientsock.sendall(data)
- except (KeyboardInterrupt,SystemExit):
- raise
- except socket.timeout:
- pass
- except:
- traceback.print_exc()
-
- try:
- clientsock.close()
- except KeyboardInterrupt:
- raise
- except:
- traceback.print_exc()
-
-
-
-
diff --git a/unp/6/dump_info.py b/unp/6/dump_info.py
deleted file mode 100644
index d351719..0000000
--- a/unp/6/dump_info.py
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin env python
-
-import sys,urllib2
-
-req=urllib2.Request(sys.argv[1])
-fd=urllib2.urlopen(req)
-
-print "Retrieved",fd.geturl()
-info=fd.info()
-
-for key,value in info.items():
- print "%s = %s " % ( key,value)
diff --git a/unp/6/dump_page.py b/unp/6/dump_page.py
deleted file mode 100644
index b550f63..0000000
--- a/unp/6/dump_page.py
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin env python
-
-import sys,urllib2
-
-req=urllib2.Request(sys.argv[1])
-fd=urllib2.urlopen(req)
-
-while 1:
- data=fd.read(1024)
- if not len(data):
- break
-
- sys.stdout.write(data)
diff --git "a/\345\215\232\345\256\242/Python yield \347\224\250\346\263\225.pdf" "b/\345\215\232\345\256\242/Python yield \347\224\250\346\263\225.pdf"
deleted file mode 100644
index 2ab8971..0000000
Binary files "a/\345\215\232\345\256\242/Python yield \347\224\250\346\263\225.pdf" and /dev/null differ
diff --git "a/\345\215\232\345\256\242/Python \344\273\243\347\240\201\346\200\247\350\203\275\344\274\230\345\214\226\346\212\200\345\267\247.pdf" "b/\345\215\232\345\256\242/Python \344\273\243\347\240\201\346\200\247\350\203\275\344\274\230\345\214\226\346\212\200\345\267\247.pdf"
deleted file mode 100644
index 3bd60a6..0000000
Binary files "a/\345\215\232\345\256\242/Python \344\273\243\347\240\201\346\200\247\350\203\275\344\274\230\345\214\226\346\212\200\345\267\247.pdf" and /dev/null differ
diff --git "a/\345\215\232\345\256\242/Python \345\274\200\345\217\221\350\200\205\345\272\224\350\257\245\347\237\245\351\201\223\347\232\204 7 \344\270\252\345\274\200\345\217\221\345\272\223.pdf" "b/\345\215\232\345\256\242/Python \345\274\200\345\217\221\350\200\205\345\272\224\350\257\245\347\237\245\351\201\223\347\232\204 7 \344\270\252\345\274\200\345\217\221\345\272\223.pdf"
deleted file mode 100644
index e77b65a..0000000
Binary files "a/\345\215\232\345\256\242/Python \345\274\200\345\217\221\350\200\205\345\272\224\350\257\245\347\237\245\351\201\223\347\232\204 7 \344\270\252\345\274\200\345\217\221\345\272\223.pdf" and /dev/null differ
diff --git "a/\345\215\232\345\256\242/python ftp\347\232\204\346\226\255\347\202\271\344\270\212\344\274\240.pdf" "b/\345\215\232\345\256\242/python ftp\347\232\204\346\226\255\347\202\271\344\270\212\344\274\240.pdf"
deleted file mode 100644
index 99c6cff..0000000
Binary files "a/\345\215\232\345\256\242/python ftp\347\232\204\346\226\255\347\202\271\344\270\212\344\274\240.pdf" and /dev/null differ
diff --git "a/\345\215\232\345\256\242/python \345\207\275\346\225\260\344\277\256\351\245\260\345\231\250.pdf" "b/\345\215\232\345\256\242/python \345\207\275\346\225\260\344\277\256\351\245\260\345\231\250.pdf"
deleted file mode 100644
index 9ffd80d..0000000
Binary files "a/\345\215\232\345\256\242/python \345\207\275\346\225\260\344\277\256\351\245\260\345\231\250.pdf" and /dev/null differ
diff --git "a/\345\215\232\345\256\242/python\345\206\231\346\225\260\346\215\256\347\273\223\346\236\204.pdf" "b/\345\215\232\345\256\242/python\345\206\231\346\225\260\346\215\256\347\273\223\346\236\204.pdf"
deleted file mode 100644
index e4af161..0000000
Binary files "a/\345\215\232\345\256\242/python\345\206\231\346\225\260\346\215\256\347\273\223\346\236\204.pdf" and /dev/null differ
diff --git "a/\345\215\232\345\256\242/python\347\210\254\350\231\253\346\212\223\347\253\231\347\232\204\346\200\273\347\273\223.pdf" "b/\345\215\232\345\256\242/python\347\210\254\350\231\253\346\212\223\347\253\231\347\232\204\346\200\273\347\273\223.pdf"
deleted file mode 100644
index c6345fe..0000000
Binary files "a/\345\215\232\345\256\242/python\347\210\254\350\231\253\346\212\223\347\253\231\347\232\204\346\200\273\347\273\223.pdf" and /dev/null differ
diff --git "a/\345\215\232\345\256\242/python\347\275\221\347\273\234\347\274\226\347\250\213-epoll.pdf" "b/\345\215\232\345\256\242/python\347\275\221\347\273\234\347\274\226\347\250\213-epoll.pdf"
deleted file mode 100644
index f260cd0..0000000
Binary files "a/\345\215\232\345\256\242/python\347\275\221\347\273\234\347\274\226\347\250\213-epoll.pdf" and /dev/null differ
diff --git "a/\345\215\232\345\256\242/python\347\275\221\347\273\234\347\274\226\347\250\213-\345\272\225\345\261\202\347\275\221\347\273\234.pdf" "b/\345\215\232\345\256\242/python\347\275\221\347\273\234\347\274\226\347\250\213-\345\272\225\345\261\202\347\275\221\347\273\234.pdf"
deleted file mode 100644
index e362f1d..0000000
Binary files "a/\345\215\232\345\256\242/python\347\275\221\347\273\234\347\274\226\347\250\213-\345\272\225\345\261\202\347\275\221\347\273\234.pdf" and /dev/null differ
diff --git "a/\345\215\232\345\256\242/python\347\275\221\347\273\234\347\274\226\347\250\213-\346\225\260\346\215\256\345\272\223.pdf" "b/\345\215\232\345\256\242/python\347\275\221\347\273\234\347\274\226\347\250\213-\346\225\260\346\215\256\345\272\223.pdf"
deleted file mode 100644
index 36a3607..0000000
Binary files "a/\345\215\232\345\256\242/python\347\275\221\347\273\234\347\274\226\347\250\213-\346\225\260\346\215\256\345\272\223.pdf" and /dev/null differ
diff --git "a/\345\215\232\345\256\242/python\351\235\242\350\257\225\351\242\230.pdf" "b/\345\215\232\345\256\242/python\351\235\242\350\257\225\351\242\230.pdf"
deleted file mode 100644
index cc562a4..0000000
Binary files "a/\345\215\232\345\256\242/python\351\235\242\350\257\225\351\242\230.pdf" and /dev/null differ