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/.gitignore b/.gitignore
new file mode 100644
index 0000000..a23d113
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,46 @@
+# Jekyll
+_site/
+.sass-cache/
+.jekyll-cache/
+.jekyll-metadata
+
+# Ruby
+Gemfile.lock
+.bundle/
+vendor/
+
+# OS
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+ehthumbs.db
+Thumbs.db
+
+# Editor
+.vscode/
+.idea/
+*.swp
+*.swo
+*~
+
+# Logs
+*.log
+
+# Runtime data
+pids
+*.pid
+*.seed
+
+# Environment variables
+.env
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+
+# Temporary files
+tmp/
+temp/
+.tmp/
\ No newline at end of file
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..a53dbb8 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,183 @@
-python
-======
-学习Python时的代码
+# 🐍 FlyPython - LLM Agent & AI Development Hub
+
+[python.flypython.com](https://python.flypython.com)
+
+## 🤖 LLM Agent Python - Core Focus
+
+### 🚀 Leading LLM Agent Frameworks
+
+#### **OpenAI Agents SDK**
+- [OpenAI Agents Python Documentation](https://openai.github.io/openai-agents-python/) - Official OpenAI Agents SDK for building AI agents
+- [OpenAI Python Library](https://github.com/openai/openai-python) - Official OpenAI Python library
+
+#### **CrewAI - Multi-Agent Systems**
+- [CrewAI Framework](https://github.com/joaomdmoura/crewAI) - Cutting-edge framework for orchestrating role-playing, autonomous AI agents
+- [CrewAI Documentation](https://docs.crewai.com/) - Official CrewAI documentation
+- [CrewAI Examples](https://github.com/joaomdmoura/crewAI-examples) - Real-world CrewAI implementations
+- [Learn Agentic AI with CrewAI](https://github.com/panaversity/learn-agentic-ai) - Comprehensive CrewAI learning resources
+
+#### **LangGraph - Advanced Agent Workflows**
+- [LangGraph](https://github.com/langchain-ai/langgraph) - Build stateful, multi-actor applications with LLMs
+- [LangChain Agent Framework](https://python.langchain.com/docs/modules/agents/) - LangChain agents and tools
+
+#### **AutoGen - Conversational AI Agents**
+- [Microsoft AutoGen](https://github.com/microsoft/autogen) - Multi-agent conversation framework
+
+#### **Dapr Agents**
+- [Dapr Agents](https://github.com/dapr/python-sdk) - Stateful virtual actors for multi-agent workflows
+
+### 🛠️ Latest Open Source LLM Agent Projects (2024)
+
+#### **Minimal & Educational**
+- [min-agent](https://github.com/zhouzaida/min-agent) - Minimal 200-line LLM Agent for understanding agent principles
+- [LangChain ReAct Agent](https://github.com/botextractai/ai-langchain-react-agent) - ReAct agent with Python REPL and DuckDuckGo Search
+- [OpenSource LLM Agents ReAct](https://github.com/Praveengovianalytics/llm_agents_open_source) - Open source LLM agents implementation
+
+#### **Production-Ready Frameworks**
+- [SuperModels](https://github.com/JohannesVC/SuperModels) - Desktop app for running LLM agents with reflection mechanisms
+- [AgentKit](https://github.com/japanvik/agentkit) - Simple framework for creating distributed LLM agents over networks
+
+#### **Specialized Applications**
+- [CrewAI Platform Examples](https://github.com/genaiworks/crewai) - Multi-agent systems with various real-world applications
+- [CrewAI Lenox](https://github.com/samurayy99/crewai_lenox) - Advanced CrewAI implementations
+
+### 📚 LLM Agent Learning Resources
+
+#### **Comprehensive Guides**
+- [Building Multi-Agent AI Systems with CrewAI](https://medium.com/neural-engineer/understanding-crewai-building-multi-agent-ai-systems-15d0236d5cbf)
+- [Agent Development Best Practices](https://cookbook.openai.com/examples/gpt4-1_prompting_guide)
+
+#### **Courses & Tutorials**
+- [Agentic AI Development Course](https://github.com/panaversity/learn-agentic-ai) - Complete course on Dapr Agentic Cloud Ascent (DACA)
+- [Python for AI and Machine Learning](https://realpython.com/learning-paths/machine-learning-python/)
+- [LangChain Agent Tutorials](https://python.langchain.com/docs/tutorials/)
+
+## 📖 Python Learning & Development
+
+### 🎯 Quick Navigation
+
+1. [Python News](#python-news)
+2. [Python Books](#python-books)
+3. [Courses](#courses)
+4. [Algorithms & Data Structures](#algorithms)
+5. [Web Development](#web-development)
+6. [Data Science & Analysis](#data-science)
+7. [Automation & Bots](#automation--bots)
+8. [Finance & Trading](#finance--trading)
+9. [Performance Optimization](#performance)
+
+---
+
+### Python News
+
+- [Python Official](https://www.python.org/)
+- [Medium Python](https://medium.com/tag/python)
+- **Reddit Communities:**
+ - [r/Python](https://www.reddit.com/r/Python/)
+ - [r/learnpython](https://www.reddit.com/r/learnpython/)
+ - [r/pythontips](https://www.reddit.com/r/pythontips/)
+ - [r/pythoncoding](https://www.reddit.com/r/pythoncoding)
+
+### Python Books
+
+#### **For Beginners**
+- **Python Crash Course: A Hands-On, Project-Based Introduction to Programming** (3rd Edition, 2023)
+ - [Amazon](https://www.amazon.com/Python-Crash-Course-Hands-Project-Based/dp/1718502702)
+
+- **Starting Out with Python** (4th Edition)
+ - [Amazon](https://www.amazon.com/Starting-Out-Python-Tony-Gaddis/dp/0134444329)
+
+- **Automate the Boring Stuff with Python** (2nd Edition)
+ - [Free Online](https://automatetheboringstuff.com/) | [Amazon](https://www.amazon.com/Automate-Boring-Stuff-Python-Programming/dp/1593279922)
+
+- **Python Cookbook: Recipes for Mastering Python 3**
+ - [Amazon](https://www.amazon.co.uk/Python-Cookbook-David-Beazley/dp/1449340377)
+
+#### **Advanced Python (2023-2024)**
+- **Effective Python: 90 Specific Ways to Write Better Python** (2nd Edition) ⭐⭐⭐⭐⭐
+ - [Amazon](https://www.amazon.com/Effective-Python-Specific-Software-Development/dp/0134853989)
+
+- **Clean Code in Python** ⭐⭐⭐⭐⭐
+ - [Amazon](https://www.amazon.com/Clean-Code-Python-maintainable-efficient/dp/1788835832)
+
+### Courses
+
+#### **Beginner Courses**
+- [Python for Everybody](https://www.coursera.org/specializations/python)
+- [Python 3 Programming](https://www.coursera.org/specializations/python-3-programming)
+
+#### **Advanced Learning**
+- [REST APIs with Flask and Python in 2024](https://www.coursera.org/learn/packt-rest-apis-with-flask-and-python-in-2024-i01az) - Professional Flask Development
+- [Financial Analysis with YFinance](https://kritjunsree.medium.com/the-2024-guide-to-using-yfinance-with-python-for-effective-stock-analysis-668a4a26ee3a) - Modern Python Finance Tools
+
+### Algorithms
+
+- [Interactive Python Coding Interview Challenges](https://github.com/donnemartin/interactive-coding-challenges) - Algorithms and data structures
+- [Algorithms: Minimal Examples in Python](https://github.com/keon/algorithms) - Data structures and algorithms
+- [Pygorithm: Learn Python Algorithms](http://pygorithm.readthedocs.io/en/latest) - Fun way to learn algorithms
+
+### Web Development
+
+#### **FastAPI**
+- [FastAPI Documentation](https://fastapi.tiangolo.com/) - Modern, fast web framework for building APIs
+- [FastAPI Best Practices](https://github.com/zhanymkanov/fastapi-best-practices)
+
+#### **Flask**
+- [REST APIs with Flask and Python in 2024](https://www.coursera.org/learn/packt-rest-apis-with-flask-and-python-in-2024-i01az)
+- [Developing RESTful APIs with Python and Flask](https://auth0.com/blog/developing-restful-apis-with-python-and-flask)
+- [Flask & Code Quality](https://flake8.pycqa.org/en/latest/user/error-codes.html)
+
+#### **Django**
+- [Complete Beginner's Guide to Django - Part 1](https://simpleisbetterthancomplex.com/series/2017/09/04/a-complete-beginners-guide-to-django-part-1.html)
+- [Build a REST API with Django](https://scotch.io/tutorials/build-a-rest-api-with-django-a-test-driven-approach-part-1)
+
+### Data Science
+
+#### **NumPy**
+- [From Python to Numpy](http://www.labri.fr/perso/nrougier/from-python-to-numpy/)
+- [Exploring Line Lengths in Python Packages](http://jakevdp.github.io/blog/2017/11/09/exploring-line-lengths-in-python-packages)
+
+#### **Matplotlib**
+- [Anatomy of Matplotlib](https://github.com/matplotlib/AnatomyOfMatplotlib)
+
+#### **Data Analysis Projects**
+- [Exploring United States Policing Data](https://blog.patricktriest.com/police-data-python)
+- [Analyzing 1000+ Greek Wines](https://tselai.com/greek-wines-analysis.html)
+- [Generate FiveThirtyEight Graphs](https://www.dataquest.io/blog/making-538-plots)
+- [Amazon Product Review Analysis](http://minimaxir.com/2017/01/amazon-spark)
+
+### Automation & Bots
+
+#### **Web Scraping**
+- [Web Scraping with Scrapy, SQL, Matplotlib](http://www.scrapingauthority.com/python-scrapy-mysql-and-matplotlib-to-gain-web-data-insights)
+- [Advanced Web Scraping: Bypassing 403 Forbidden](http://sangaline.com/post/advanced-web-scraping-tutorial)
+- [Mastering Python Web Scraping](https://hackernoon.com/mastering-python-web-scraping-get-your-data-back-e9a5cc653d88)
+
+#### **Automation Projects**
+- [Wedding Automation with Twilio and Python](https://www.twilio.com/blog/2017/04/wedding-at-scale-how-i-used-twilio-python-and-google-to-automate-my-wedding.html)
+- [Finding Interesting People on Medium](https://medium.freecodecamp.org/how-i-used-python-to-find-interesting-people-on-medium-be9261b924b0)
+
+#### **Bots**
+- [Reddit + Facebook Messenger Bot](https://pythontips.com/2017/04/13/making-a-reddit-facebook-messenger-bot)
+- [Instagram Bot Success Story](https://medium.freecodecamp.com/my-open-source-instagram-bot-got-me-2-500-real-followers-for-5-in-server-costs-e40491358340)
+
+#### **Spreadsheets Integration**
+- [Python Excel Tutorial: The Definitive Guide](https://hackernoon.com/python-excel-tutorial-the-definitive-guide-934ee6dd15b0)
+- [Data Analysis with Python in Excel](https://learning.anaconda.cloud/anaconda-certified-data-analysis-with-python-in-excel)
+- [Google Sheets and Python](https://www.youtube.com/watch?v=vISRn5qFrkM)
+
+### Finance & Trading
+
+- [2024 Guide to YFinance for Stock Analysis](https://kritjunsree.medium.com/the-2024-guide-to-using-yfinance-with-python-for-effective-stock-analysis-668a4a26ee3a)
+- [Quantitative Trading with Python](https://medium.com/@deepml1818/quantitative-trading-with-python-analyzing-financial-data-7c829d447e0a)
+- [Financial Data with Alpha Vantage 2024](https://medium.com/@datavisiondallas/navigating-financial-data-with-python-and-alpha-vantage-in-2024-a-beginners-guide-ca005bb1a6c2)
+- [Stock Price Data - Python for Finance](https://www.youtube.com/watch?v=2BrpKpWwT2A)
+- [Analyzing Cryptocurrency Markets](https://blog.patricktriest.com/analyzing-cryptocurrencies-python)
+
+
+
+### Performance
+
+- [Million Requests per Second with Python](https://medium.freecodecamp.com/million-requests-per-second-with-python-95c137af319)
+- [Yes, Python is Slow, and I Don't Care](https://hackernoon.com/yes-python-is-slow-and-i-dont-care-13763980b5a1)
+- [Memoization in Python](https://dbader.org/blog/python-memoization)
diff --git a/README_cn.md b/README_cn.md
new file mode 100644
index 0000000..c8c7945
--- /dev/null
+++ b/README_cn.md
@@ -0,0 +1,184 @@
+# 🐍 FlyPython - LLM Agent 与 AI 开发中心
+
+[python.flypython.com](https://python.flypython.com)
+
+## 🤖 LLM Agent Python - 核心重点
+
+### 🚀 主流 LLM Agent 框架
+
+#### **OpenAI Agents SDK**
+- [OpenAI Agents Python 文档](https://openai.github.io/openai-agents-python/) - 官方 OpenAI Agents SDK 用于构建 AI 智能体
+- [OpenAI Python 库](https://github.com/openai/openai-python) - 官方 OpenAI Python 库
+
+#### **CrewAI - 多智能体系统**
+- [CrewAI 框架](https://github.com/joaomdmoura/crewAI) - 用于协调角色扮演、自主 AI 智能体的尖端框架
+- [CrewAI 文档](https://docs.crewai.com/) - 官方 CrewAI 文档
+- [CrewAI 示例](https://github.com/joaomdmoura/crewAI-examples) - 真实世界 CrewAI 实现案例
+- [使用 CrewAI 学习 Agentic AI](https://github.com/panaversity/learn-agentic-ai) - 综合 CrewAI 学习资源
+
+#### **LangGraph - 高级智能体工作流**
+- [LangGraph](https://github.com/langchain-ai/langgraph) - 使用 LLM 构建有状态的多角色应用程序
+- [LangChain Agent 框架](https://python.langchain.com/docs/modules/agents/) - LangChain 智能体和工具
+
+#### **AutoGen - 对话式 AI 智能体**
+- [Microsoft AutoGen](https://github.com/microsoft/autogen) - 多智能体对话框架
+
+#### **Dapr Agents**
+- [Dapr Agents](https://github.com/dapr/python-sdk) - 用于多智能体工作流的有状态虚拟角色
+
+### 🛠️ 最新开源 LLM Agent 项目 (2024)
+
+#### **极简与教育性项目**
+- [min-agent](https://github.com/zhouzaida/min-agent) - 极简 200 行 LLM Agent,用于理解智能体原理
+- [LangChain ReAct Agent](https://github.com/botextractai/ai-langchain-react-agent) - 带有 Python REPL 和 DuckDuckGo 搜索的 ReAct 智能体
+- [开源 LLM Agents ReAct](https://github.com/Praveengovianalytics/llm_agents_open_source) - 开源 LLM 智能体实现
+
+#### **生产就绪框架**
+- [SuperModels](https://github.com/JohannesVC/SuperModels) - 具有反思机制的 LLM 智能体桌面应用
+- [AgentKit](https://github.com/japanvik/agentkit) - 用于创建网络分布式 LLM 智能体的简单框架
+
+#### **专业应用**
+- [CrewAI 平台示例](https://github.com/genaiworks/crewai) - 多种真实世界应用的多智能体系统
+- [CrewAI Lenox](https://github.com/samurayy99/crewai_lenox) - 高级 CrewAI 实现
+
+### 📚 LLM Agent 学习资源
+
+#### **综合指南**
+- [使用 CrewAI 构建多智能体 AI 系统](https://medium.com/neural-engineer/understanding-crewai-building-multi-agent-ai-systems-15d0236d5cbf)
+- [智能体开发最佳实践](https://cookbook.openai.com/examples/gpt4-1_prompting_guide)
+
+#### **课程与教程**
+- [Agentic AI 开发课程](https://github.com/panaversity/learn-agentic-ai) - Dapr Agentic Cloud Ascent (DACA) 完整课程
+- [Python 人工智能和机器学习](https://realpython.com/learning-paths/machine-learning-python/)
+- [LangChain Agent 教程](https://python.langchain.com/docs/tutorials/)
+
+## 📖 Python 学习与开发
+
+### 🎯 快速导航
+
+1. [Python 新闻](#python-新闻)
+2. [Python 书籍](#python-书籍)
+3. [课程](#课程)
+4. [算法与数据结构](#算法)
+5. [Web 开发](#web-开发)
+6. [数据科学与分析](#数据科学)
+7. [自动化与机器人](#自动化与机器人)
+8. [金融与交易](#金融与交易)
+9. [性能优化](#性能优化)
+
+---
+
+### Python 新闻
+
+- [Python 官方](https://www.python.org/)
+- [Medium Python](https://medium.com/tag/python)
+- **Reddit 社区:**
+ - [r/Python](https://www.reddit.com/r/Python/)
+ - [r/learnpython](https://www.reddit.com/r/learnpython/)
+ - [r/pythontips](https://www.reddit.com/r/pythontips/)
+ - [r/pythoncoding](https://www.reddit.com/r/pythoncoding)
+
+### Python 书籍
+
+#### **初学者**
+- **Python 编程从入门到实践** (第3版, 2023)
+ - [Amazon](https://www.amazon.com/Python-Crash-Course-Hands-Project-Based/dp/1718502702)
+
+- **Python 编程入门** (第4版)
+ - [Amazon](https://www.amazon.com/Starting-Out-Python-Tony-Gaddis/dp/0134444329)
+
+- **Python 编程快速上手:让繁琐工作自动化** (第2版)
+ - [免费在线](https://automatetheboringstuff.com/) | [Amazon](https://www.amazon.com/Automate-Boring-Stuff-Python-Programming/dp/1593279922)
+
+- **Python Cookbook:掌握 Python 3 的秘诀**
+ - [Amazon](https://www.amazon.co.uk/Python-Cookbook-David-Beazley/dp/1449340377)
+
+#### **高级 Python (2023-2024)**
+- **Effective Python:编写高质量 Python 代码的 90 个建议** (第2版) ⭐⭐⭐⭐⭐
+ - [Amazon](https://www.amazon.com/Effective-Python-Specific-Software-Development/dp/0134853989)
+
+- **Python 代码整洁之道** ⭐⭐⭐⭐⭐
+ - [Amazon](https://www.amazon.com/Clean-Code-Python-maintainable-efficient/dp/1788835832)
+
+### 课程
+
+#### **初学者课程**
+- [Python for Everybody](https://www.coursera.org/specializations/python)
+- [Python 3 编程](https://www.coursera.org/specializations/python-3-programming)
+
+#### **高级学习**
+- [2024 年 Flask 和 Python REST API](https://www.coursera.org/learn/packt-rest-apis-with-flask-and-python-in-2024-i01az) - 专业 Flask 开发
+- [YFinance 金融分析](https://kritjunsree.medium.com/the-2024-guide-to-using-yfinance-with-python-for-effective-stock-analysis-668a4a26ee3a) - 现代 Python 金融工具
+
+### 算法
+
+- [Python 交互式编程面试挑战](https://github.com/donnemartin/interactive-coding-challenges) - 算法和数据结构
+- [算法:Python 中的最小示例](https://github.com/keon/algorithms) - 数据结构和算法
+- [Pygorithm:学习 Python 算法](http://pygorithm.readthedocs.io/en/latest) - 学习算法的有趣方式
+
+### Web 开发
+
+#### **FastAPI**
+- [FastAPI 文档](https://fastapi.tiangolo.com/) - 现代、快速的 API 构建 Web 框架
+- [FastAPI 最佳实践](https://github.com/zhanymkanov/fastapi-best-practices)
+
+#### **Flask**
+- [2024 年 Flask 和 Python REST API](https://www.coursera.org/learn/packt-rest-apis-with-flask-and-python-in-2024-i01az)
+- [使用 Python 和 Flask 开发 RESTful API](https://auth0.com/blog/developing-restful-apis-with-python-and-flask)
+- [Flask 与代码质量](https://flake8.pycqa.org/en/latest/user/error-codes.html)
+
+#### **Django**
+- [Django 完全初学者指南 - 第1部分](https://simpleisbetterthancomplex.com/series/2017/09/04/a-complete-beginners-guide-to-django-part-1.html)
+- [使用 Django 构建 REST API](https://scotch.io/tutorials/build-a-rest-api-with-django-a-test-driven-approach-part-1)
+
+### 数据科学
+
+#### **NumPy**
+- [从 Python 到 Numpy](http://www.labri.fr/perso/nrougier/from-python-to-numpy/)
+- [探索 Python 包中的行长度](http://jakevdp.github.io/blog/2017/11/09/exploring-line-lengths-in-python-packages)
+
+#### **Matplotlib**
+- [Matplotlib 剖析](https://github.com/matplotlib/AnatomyOfMatplotlib)
+
+#### **数据分析项目**
+- [探索美国警务数据](https://blog.patricktriest.com/police-data-python)
+- [分析 1000+ 希腊葡萄酒](https://tselai.com/greek-wines-analysis.html)
+- [生成 FiveThirtyEight 图表](https://www.dataquest.io/blog/making-538-plots)
+- [亚马逊产品评论分析](http://minimaxir.com/2017/01/amazon-spark)
+
+### 自动化与机器人
+
+#### **网页抓取**
+- [使用 Scrapy、SQL、Matplotlib 进行网页抓取](http://www.scrapingauthority.com/python-scrapy-mysql-and-matplotlib-to-gain-web-data-insights)
+- [高级网页抓取:绕过 403 禁止](http://sangaline.com/post/advanced-web-scraping-tutorial)
+- [掌握 Python 网页抓取](https://hackernoon.com/mastering-python-web-scraping-get-your-data-back-e9a5cc653d88)
+
+#### **自动化项目**
+- [使用 Twilio 和 Python 的婚礼自动化](https://www.twilio.com/blog/2017/04/wedding-at-scale-how-i-used-twilio-python-and-google-to-automate-my-wedding.html)
+- [在 Medium 上寻找有趣的人](https://medium.freecodecamp.org/how-i-used-python-to-find-interesting-people-on-medium-be9261b924b0)
+
+#### **机器人**
+- [Reddit + Facebook Messenger 机器人](https://pythontips.com/2017/04/13/making-a-reddit-facebook-messenger-bot)
+- [Instagram 机器人成功故事](https://medium.freecodecamp.com/my-open-source-instagram-bot-got-me-2-500-real-followers-for-5-in-server-costs-e40491358340)
+
+#### **电子表格集成**
+- [Python Excel 教程:权威指南](https://hackernoon.com/python-excel-tutorial-the-definitive-guide-934ee6dd15b0)
+- [在 Excel 中使用 Python 进行数据分析](https://learning.anaconda.cloud/anaconda-certified-data-analysis-with-python-in-excel)
+- [Google Sheets 和 Python](https://www.youtube.com/watch?v=vISRn5qFrkM)
+
+### 金融与交易
+
+- [2024 年 YFinance 股票分析指南](https://kritjunsree.medium.com/the-2024-guide-to-using-yfinance-with-python-for-effective-stock-analysis-668a4a26ee3a)
+- [使用 Python 进行量化交易](https://medium.com/@deepml1818/quantitative-trading-with-python-analyzing-financial-data-7c829d447e0a)
+- [2024 年 Alpha Vantage 金融数据](https://medium.com/@datavisiondallas/navigating-financial-data-with-python-and-alpha-vantage-in-2024-a-beginners-guide-ca005bb1a6c2)
+- [股票价格数据 - Python 金融编程](https://www.youtube.com/watch?v=2BrpKpWwT2A)
+- [分析加密货币市场](https://blog.patricktriest.com/analyzing-cryptocurrencies-python)
+
+
+### 性能优化
+
+- [Python 每秒百万请求](https://medium.freecodecamp.com/million-requests-per-second-with-python-95c137af319)
+- [是的,Python 很慢,但我不在乎](https://hackernoon.com/yes-python-is-slow-and-i-dont-care-13763980b5a1)
+- [Python 中的记忆化](https://dbader.org/blog/python-memoization)
+
+
diff --git a/_config.yml b/_config.yml
new file mode 100644
index 0000000..bfc1f36
--- /dev/null
+++ b/_config.yml
@@ -0,0 +1,134 @@
+# Site settings
+title: FlyPython
+subtitle: Python Learning Resource Hub
+description: >-
+ FlyPython is a carefully curated collection of Python learning resources,
+ including tutorials, books, courses, tools, and best practices to support
+ Python learners from beginners to advanced developers.
+
+# Site information
+url: "https://python.flypython.com"
+baseurl: ""
+
+# Author information
+author:
+ name: FlyPython
+ email: hello@flypython.com
+ github: flypython
+ twitter: flypython
+
+# Build settings
+markdown: kramdown
+highlighter: rouge
+permalink: pretty
+
+# Theme configuration - Using GitHub Pages compatible theme
+remote_theme: pages-themes/cayman@v0.2.0
+
+# Plugins (GitHub Pages whitelist)
+plugins:
+ - jekyll-feed
+ - jekyll-sitemap
+ - jekyll-seo-tag
+ - jekyll-optional-front-matter
+ - jekyll-readme-index
+ - jekyll-relative-links
+
+# SEO settings
+lang: en
+logo: /assets/images/logo.png
+
+# Social links
+github_username: flypython
+twitter_username: flypython
+
+# Navigation
+header_pages:
+ - README.md
+ - README_cn.md
+
+# GitHub Pages safe collections
+collections:
+ tutorials:
+ output: true
+ permalink: /:collection/:name/
+ resources:
+ output: true
+ permalink: /:collection/:name/
+
+# Defaults
+defaults:
+ - scope:
+ path: ""
+ type: "posts"
+ values:
+ layout: "post"
+ author: "FlyPython"
+ - scope:
+ path: ""
+ type: "pages"
+ values:
+ layout: "page"
+ - scope:
+ path: "README.md"
+ values:
+ layout: "default"
+ title: "FlyPython - Python Learning Resources"
+ description: "A curated collection of Python learning resources including tutorials, books, courses, and best practices for developers at all levels."
+ lang: "en"
+ permalink: "/"
+ - scope:
+ path: "README_cn.md"
+ values:
+ layout: "default"
+ title: "FlyPython - Python 学习资源"
+ description: "精心策划的 Python 学习资源集合,包含教程、书籍、课程和各级别开发者的最佳实践。"
+ lang: "zh-CN"
+ permalink: "/README_cn.html"
+ - scope:
+ path: ""
+ type: "tutorials"
+ values:
+ layout: "tutorial"
+ - scope:
+ path: ""
+ type: "resources"
+ values:
+ layout: "resource"
+
+# Analytics (optional)
+google_analytics: # UA-XXXXXXXX-X
+
+# Features
+show_downloads: false
+show_github_ribbon: false
+
+# Custom variables
+github:
+ repository_url: https://github.com/flypython/python
+ repository_name: flypython/python
+
+# Content settings
+kramdown:
+ input: GFM
+ hard_wrap: false
+ syntax_highlighter: rouge
+ syntax_highlighter_opts:
+ css_class: 'highlight'
+ span:
+ line_numbers: false
+ block:
+ line_numbers: true
+
+# Exclude from processing
+exclude:
+ - Gemfile
+ - Gemfile.lock
+ - node_modules
+ - vendor/bundle/
+ - vendor/cache/
+ - vendor/gems/
+ - vendor/ruby/
+ - tools/
+ - link_audit_report.md
+ - content_update_summary.md
\ No newline at end of file
diff --git a/_data/navigation.yml b/_data/navigation.yml
new file mode 100644
index 0000000..8555b4a
--- /dev/null
+++ b/_data/navigation.yml
@@ -0,0 +1,46 @@
+main:
+ - title: "🏠 Home"
+ url: "/"
+ - title: "🇨🇳 中文版"
+ url: "/README_cn.html"
+ - title: "📚 Resources"
+ url: "#resources"
+ children:
+ - title: "📖 Tutorials"
+ url: "#tutorials"
+ - title: "📚 Books"
+ url: "#books"
+ - title: "🎓 Courses"
+ url: "#courses"
+ - title: "🛠️ Tools"
+ url: "#tools"
+ - title: "🤖 AI/ML"
+ url: "#ai-ml"
+ children:
+ - title: "🧠 LLM"
+ url: "#python-for-llm"
+ - title: "📊 Data Science"
+ url: "#data-science"
+ - title: "💹 Finance"
+ url: "#finance"
+ - title: "🔗 GitHub"
+ url: "https://github.com/flypython/python"
+ external: true
+
+footer:
+ - title: "Quick Links"
+ children:
+ - title: "Python.org"
+ url: "https://python.org"
+ - title: "PyPI"
+ url: "https://pypi.org"
+ - title: "Real Python"
+ url: "https://realpython.com"
+ - title: "Community"
+ children:
+ - title: "Reddit r/Python"
+ url: "https://reddit.com/r/Python"
+ - title: "Stack Overflow"
+ url: "https://stackoverflow.com/questions/tagged/python"
+ - title: "Python Discord"
+ url: "https://discord.gg/python"
\ No newline at end of file
diff --git a/_includes/head-custom.html b/_includes/head-custom.html
new file mode 100644
index 0000000..ef883a9
--- /dev/null
+++ b/_includes/head-custom.html
@@ -0,0 +1,215 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/_layouts/default.html b/_layouts/default.html
new file mode 100644
index 0000000..3c0f24e
--- /dev/null
+++ b/_layouts/default.html
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+ {% seo %}
+
+
+
+
+
+
+
+ {% include head-custom.html %}
+
+
+ Skip to the content.
+
+
+
+
+
+ {% if content contains '##' %}
+
+ {% endif %}
+
+ {{ content }}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/css/custom.css b/assets/css/custom.css
new file mode 100644
index 0000000..c249f6e
--- /dev/null
+++ b/assets/css/custom.css
@@ -0,0 +1,417 @@
+/* Custom CSS for FlyPython */
+
+/* Enhanced Typography */
+body {
+ font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
+ line-height: 1.8;
+}
+
+/* Language Toggle Styles */
+.language-toggle {
+ margin: 1rem 0;
+ text-align: center;
+}
+
+.btn-lang {
+ display: inline-block;
+ margin: 0 0.25rem;
+ padding: 0.5rem 1rem;
+ background-color: rgba(255, 255, 255, 0.2);
+ color: white;
+ text-decoration: none;
+ border-radius: 0.3rem;
+ border: 1px solid rgba(255, 255, 255, 0.3);
+ transition: all 0.2s ease;
+ /* Ensure buttons are not affected by generic .btn styles */
+ transform: none !important;
+ box-shadow: none;
+}
+
+.btn-lang:hover {
+ background-color: rgba(255, 255, 255, 0.3);
+ border-color: rgba(255, 255, 255, 0.5);
+ text-decoration: none;
+ color: white;
+ /* Disable transform effects on hover */
+ transform: none !important;
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
+}
+
+.btn-lang.active {
+ background-color: rgba(255, 255, 255, 0.9);
+ color: #333;
+ border-color: rgba(255, 255, 255, 0.9);
+ transform: none !important;
+}
+
+/* Header Stats */
+.header-stats {
+ margin-top: 1rem;
+ padding: 0.75rem 1rem;
+ background: rgba(255, 255, 255, 0.1);
+ border-radius: 0.5rem;
+ backdrop-filter: blur(10px);
+ border: 1px solid rgba(255, 255, 255, 0.2);
+}
+
+.header-stats p {
+ margin: 0;
+ color: rgba(255, 255, 255, 0.9);
+ font-size: 0.9rem;
+ text-align: center;
+ font-weight: 300;
+}
+
+.header-stats a {
+ color: rgba(255, 255, 255, 0.95);
+ text-decoration: none;
+ transition: all 0.2s ease;
+}
+
+.header-stats a:hover {
+ color: white;
+ text-decoration: none;
+}
+
+.header-stats img {
+ vertical-align: middle;
+ margin-left: 0.25rem;
+}
+
+/* Enhanced Header */
+.page-header {
+ background: linear-gradient(135deg, #157878 0%, #2c3e50 100%);
+}
+
+.project-name {
+ font-size: 3rem;
+ font-weight: 700;
+ text-shadow: 0 2px 4px rgba(0,0,0,0.3);
+}
+
+.project-tagline {
+ font-size: 1.2rem;
+ font-weight: 300;
+ opacity: 0.9;
+}
+
+/* Enhanced Buttons - Only affects GitHub buttons, not language toggle buttons */
+.btn:not(.btn-lang) {
+ transition: all 0.3s ease;
+}
+
+.btn:not(.btn-lang):hover {
+ transform: translateY(-2px);
+ box-shadow: 0 4px 8px rgba(0,0,0,0.2);
+}
+
+/* Table of Contents Styles */
+.toc {
+ background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
+ border: 1px solid #dee2e6;
+ border-radius: 0.5rem;
+ padding: 1.5rem;
+ margin: 2rem 0;
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
+}
+
+.toc h3 {
+ margin-top: 0;
+ color: #495057;
+ font-size: 1.2rem;
+ border-bottom: 2px solid #157878;
+ padding-bottom: 0.5rem;
+}
+
+.toc ul {
+ list-style: none;
+ padding-left: 0;
+}
+
+.toc li {
+ margin: 0.5rem 0;
+}
+
+.toc a {
+ color: #157878;
+ text-decoration: none;
+ padding: 0.25rem 0.5rem;
+ border-radius: 0.25rem;
+ transition: all 0.2s ease;
+ display: block;
+}
+
+.toc a:hover {
+ background-color: #157878;
+ color: white;
+ text-decoration: none;
+}
+
+.toc-level-2 {
+ padding-left: 1rem;
+}
+
+.toc-level-3 {
+ padding-left: 2rem;
+}
+
+/* Enhanced Main Content */
+.main-content {
+ line-height: 1.8;
+}
+
+.main-content h1,
+.main-content h2,
+.main-content h3,
+.main-content h4 {
+ color: #2c3e50;
+ margin-top: 2rem;
+ margin-bottom: 1rem;
+}
+
+.main-content h2 {
+ border-bottom: 2px solid #157878;
+ padding-bottom: 0.5rem;
+}
+
+.main-content h3 {
+ border-left: 4px solid #157878;
+ padding-left: 1rem;
+}
+
+/* Code block enhancements */
+.main-content pre {
+ background: #2d3748;
+ border-radius: 0.5rem;
+ padding: 1.5rem;
+ overflow-x: auto;
+}
+
+.main-content code {
+ background: #f1f3f4;
+ color: #d73a49;
+ padding: 0.2rem 0.4rem;
+ border-radius: 0.25rem;
+ font-size: 0.9em;
+}
+
+.main-content pre code {
+ background: none;
+ color: #e2e8f0;
+ padding: 0;
+}
+
+/* Link styles */
+.main-content a {
+ color: #157878;
+ text-decoration: none;
+ border-bottom: 1px solid transparent;
+ transition: all 0.2s ease;
+}
+
+.main-content a:hover {
+ border-bottom-color: #157878;
+ text-decoration: none;
+}
+
+/* Enhanced lists */
+.main-content ul li {
+ margin: 0.75rem 0;
+}
+
+.main-content ul li a {
+ font-weight: 500;
+}
+
+.main-content ul li a:hover {
+ background: rgba(21, 120, 120, 0.1);
+ padding: 0.2rem 0.4rem;
+ border-radius: 0.25rem;
+ margin: -0.2rem -0.4rem;
+}
+
+/* Footer enhancements */
+.site-footer {
+ border-top: 2px solid #157878;
+ margin-top: 3rem;
+ padding-top: 2rem;
+}
+
+.footer-stats {
+ text-align: center;
+ margin-top: 1rem;
+ padding: 1rem;
+ background: #f8f9fa;
+ border-radius: 0.5rem;
+}
+
+.footer-stats p {
+ margin: 0;
+ color: #6c757d;
+}
+
+/* Scroll to top button */
+.scroll-to-top {
+ position: fixed;
+ bottom: 2rem;
+ right: 2rem;
+ background: #157878;
+ color: white;
+ border: none;
+ border-radius: 50%;
+ width: 3rem;
+ height: 3rem;
+ cursor: pointer;
+ opacity: 0;
+ transition: opacity 0.3s ease;
+ z-index: 1000;
+ font-size: 1.2rem;
+}
+
+.scroll-to-top.show {
+ opacity: 1;
+}
+
+.scroll-to-top:hover {
+ background: #2c3e50;
+}
+
+/* Resource cards */
+.resource-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
+ gap: 2rem;
+ margin: 2rem 0;
+}
+
+.resource-card {
+ background: white;
+ border-radius: 0.5rem;
+ padding: 1.5rem;
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
+ transition: all 0.3s ease;
+ border-left: 4px solid #157878;
+}
+
+.resource-card:hover {
+ transform: translateY(-4px);
+ box-shadow: 0 8px 25px rgba(0,0,0,0.15);
+}
+
+/* Category headers */
+.category-header {
+ display: flex;
+ align-items: center;
+ margin: 3rem 0 1.5rem 0;
+ padding: 1rem;
+ background: linear-gradient(135deg, rgba(21, 120, 120, 0.1) 0%, rgba(21, 120, 120, 0.05) 100%);
+ border-radius: 0.5rem;
+ border-left: 5px solid #157878;
+}
+
+/* Statistics section */
+.stats-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
+ gap: 1rem;
+ margin: 2rem 0;
+}
+
+.stat-card {
+ background: white;
+ padding: 1.5rem;
+ border-radius: 0.5rem;
+ text-align: center;
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
+ border-top: 3px solid #157878;
+}
+
+.stat-number {
+ font-size: 2.5rem;
+ font-weight: bold;
+ color: #157878;
+ display: block;
+}
+
+.stat-label {
+ color: #666;
+ font-size: 0.9rem;
+ text-transform: uppercase;
+ letter-spacing: 0.5px;
+}
+
+/* Responsive improvements */
+@media screen and (max-width: 768px) {
+ .project-name {
+ font-size: 2rem;
+ }
+
+ .project-tagline {
+ font-size: 1rem;
+ }
+
+ .language-toggle {
+ text-align: center;
+ }
+
+ .btn-lang {
+ display: block;
+ margin: 0.5rem auto;
+ max-width: 200px;
+ }
+
+ .header-stats {
+ margin: 1rem 0;
+ padding: 0.5rem;
+ }
+
+ .header-stats p {
+ font-size: 0.8rem;
+ line-height: 1.4;
+ }
+
+ .toc {
+ margin: 1rem 0;
+ padding: 1rem;
+ }
+
+ .resource-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .stats-grid {
+ grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
+ }
+}
+
+/* Dark mode support */
+@media (prefers-color-scheme: dark) {
+ .resource-card {
+ background: #2d3748;
+ color: #e2e8f0;
+ }
+
+ .stat-card {
+ background: #2d3748;
+ color: #e2e8f0;
+ }
+
+ .footer-stats {
+ background: #2d3748;
+ color: #e2e8f0;
+ }
+}
+
+/* Print styles */
+@media print {
+ .page-header,
+ .site-footer,
+ .scroll-to-top,
+ .toc {
+ display: none !important;
+ }
+
+ .main-content {
+ max-width: none !important;
+ }
+}
\ 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/robots.txt b/robots.txt
new file mode 100644
index 0000000..d909cd5
--- /dev/null
+++ b/robots.txt
@@ -0,0 +1,19 @@
+User-agent: *
+Allow: /
+
+# Sitemap
+Sitemap: https://python.flypython.com/sitemap.xml
+
+# Specific directives
+Disallow: /tools/
+Disallow: /*.json$
+Disallow: /assets/css/
+Disallow: /assets/js/
+
+# Allow all important pages
+Allow: /README.md
+Allow: /README_cn.html
+Allow: /
+
+# Crawl delay (optional)
+Crawl-delay: 1
\ No newline at end of file
diff --git a/tools/check_links.py b/tools/check_links.py
new file mode 100644
index 0000000..627fcbc
--- /dev/null
+++ b/tools/check_links.py
@@ -0,0 +1,189 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""
+FlyPython 链接检查工具
+用于定期检查README文件中所有外部链接的有效性
+"""
+
+import re
+import requests
+import time
+import json
+import os
+from urllib.parse import urlparse
+from concurrent.futures import ThreadPoolExecutor, as_completed
+
+class LinkChecker:
+ def __init__(self):
+ self.session = requests.Session()
+ self.session.headers.update({
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
+ })
+ self.timeout = 10
+ self.results = {
+ 'working': [],
+ 'broken': [],
+ 'redirect': [],
+ 'timeout': [],
+ 'unknown': []
+ }
+
+ def extract_links_from_file(self, filename):
+ """从markdown文件中提取所有外部链接"""
+ try:
+ with open(filename, 'r', encoding='utf-8') as f:
+ content = f.read()
+ except Exception as e:
+ print(f"无法读取文件 {filename}: {e}")
+ return []
+
+ # 匹配markdown链接格式 [text](url)
+ markdown_links = re.findall(r'\[([^\]]*)\]\(([^)]+)\)', content)
+
+ # 匹配纯链接格式
+ url_pattern = r'https?://[^\s\])\}]+'
+ plain_links = re.findall(url_pattern, content)
+
+ links = []
+
+ # 处理markdown链接
+ for text, url in markdown_links:
+ if url.startswith('http'):
+ links.append({
+ 'text': text,
+ 'url': url,
+ 'file': filename,
+ 'type': 'markdown'
+ })
+
+ # 处理纯链接
+ for url in plain_links:
+ # 避免重复
+ if not any(link['url'] == url for link in links):
+ links.append({
+ 'text': url,
+ 'url': url,
+ 'file': filename,
+ 'type': 'plain'
+ })
+
+ return links
+
+ def check_link(self, link):
+ """检查单个链接的状态"""
+ url = link['url']
+ try:
+ response = self.session.head(url, timeout=self.timeout, allow_redirects=True)
+ status_code = response.status_code
+
+ if status_code == 200:
+ link['status'] = 'working'
+ link['status_code'] = status_code
+ self.results['working'].append(link)
+ elif 300 <= status_code < 400:
+ link['status'] = 'redirect'
+ link['status_code'] = status_code
+ link['final_url'] = response.url
+ self.results['redirect'].append(link)
+ else:
+ # 尝试GET请求,有些网站不支持HEAD
+ try:
+ response = self.session.get(url, timeout=self.timeout)
+ if response.status_code == 200:
+ link['status'] = 'working'
+ link['status_code'] = response.status_code
+ self.results['working'].append(link)
+ else:
+ link['status'] = 'broken'
+ link['status_code'] = response.status_code
+ self.results['broken'].append(link)
+ except:
+ link['status'] = 'broken'
+ link['status_code'] = status_code
+ self.results['broken'].append(link)
+
+ except requests.exceptions.Timeout:
+ link['status'] = 'timeout'
+ link['error'] = 'Request timeout'
+ self.results['timeout'].append(link)
+
+ except requests.exceptions.RequestException as e:
+ link['status'] = 'unknown'
+ link['error'] = str(e)
+ self.results['unknown'].append(link)
+
+ return link
+
+ def check_all_links(self, links, max_workers=10):
+ """并发检查所有链接"""
+ print(f"开始检查 {len(links)} 个链接...")
+
+ with ThreadPoolExecutor(max_workers=max_workers) as executor:
+ future_to_link = {executor.submit(self.check_link, link): link for link in links}
+
+ for i, future in enumerate(as_completed(future_to_link), 1):
+ link = future_to_link[future]
+ try:
+ result = future.result()
+ status = result.get('status', 'unknown')
+ print(f"[{i}/{len(links)}] {status.upper()}: {result['url']}")
+ time.sleep(0.1)
+ except Exception as e:
+ print(f"检查链接时出错 {link['url']}: {e}")
+
+ def generate_report(self):
+ """生成检查报告"""
+ total = sum(len(links) for links in self.results.values())
+
+ print("\n" + "="*60)
+ print("链接检查报告")
+ print("="*60)
+ print(f"总链接数: {total}")
+ print(f"正常链接: {len(self.results['working'])}")
+ print(f"重定向链接: {len(self.results['redirect'])}")
+ print(f"失效链接: {len(self.results['broken'])}")
+ print(f"超时链接: {len(self.results['timeout'])}")
+ print(f"未知状态: {len(self.results['unknown'])}")
+
+ # 保存详细结果
+ os.makedirs('../reports', exist_ok=True)
+ with open('../reports/link_check_results.json', 'w', encoding='utf-8') as f:
+ json.dump(self.results, f, ensure_ascii=False, indent=2)
+
+ print(f"\n详细结果已保存到: reports/link_check_results.json")
+
+def main():
+ checker = LinkChecker()
+
+ # 从README文件提取链接 (相对于项目根目录)
+ files_to_check = ['../README.md', '../README_cn.md']
+ all_links = []
+
+ for filename in files_to_check:
+ print(f"从 {filename} 提取链接...")
+ links = checker.extract_links_from_file(filename)
+ all_links.extend(links)
+ print(f"找到 {len(links)} 个链接")
+
+ if not all_links:
+ print("没有找到任何链接!")
+ return
+
+ # 去重
+ unique_links = []
+ seen_urls = set()
+ for link in all_links:
+ if link['url'] not in seen_urls:
+ unique_links.append(link)
+ seen_urls.add(link['url'])
+
+ print(f"去重后共 {len(unique_links)} 个唯一链接")
+
+ # 检查链接
+ checker.check_all_links(unique_links)
+
+ # 生成报告
+ checker.generate_report()
+
+if __name__ == '__main__':
+ main()
\ No newline at end of file
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