StartFlagV2 程序可以手机删除的程序恢复吗

当前位置:
2015 年 1 月 11 日
2014 年 8 月 3 日
2014 年 6 月 26 日
2014 年 4 月 25 日
欢迎提交您的建议:
*输入验证码:Keyboard Shortcuts?
Next menu item
Previous menu item
Previous man page
Next man page
Scroll to bottom
Scroll to top
Goto homepage
Goto search(current page)
Focus search box
PHP is a popular general-purpose scripting language that is especially suited to web development.
Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.
02 Aug 2018
The PHP team is glad to announce the release of the fifth PHP 7.3.0 version, PHP 7.3.0beta1.
The rough outline of the PHP 7.3 release cycle is specified in the
For source downloads of PHP 7.3.0beta1 please visit the .
Windows sources and binaries can be found on .
Please carefully test this version and report any issues found in the .
THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION!
For more information on the new features and other changes, you can read the
file for a complete list of upgrading notes. These files can also be found in the release archive.
The next release would be Beta 2, planned for August 16th.
The signatures for the release can be found in
Thank you for helping us make PHP better.
20 Jul 2018
The PHP development team announces the immediate availability of PHP
7.1.20. This is a security release. Several security bugs have been fixed
in this release.
All PHP 7.1 users are encouraged to upgrade to this version.
For source downloads of PHP 7.1.20 please visit our ,
Windows source and binaries can be found on .
The list of changes is recorded in the .
20 Jul 2018
The PHP development team announces the immediate availability of PHP
5.6.37. This is a security release. Several security bugs have been fixed
in this release.
All PHP 5.6 users are encouraged to upgrade to this version.
For source downloads of PHP 5.6.37 please visit our ,
Windows source and binaries can be found on .
The list of changes is recorded in the .
19 Jul 2018
The PHP development team announces the immediate availability of PHP
7.0.31. This is a security release. Several security bugs have been fixed
in this release.
All PHP 7.0 users are encouraged to upgrade to this version.
For source downloads of PHP 7.0.31 please visit our ,
Windows source and binaries can be found on .
The list of changes is recorded in the .
19 Jul 2018
The PHP development team announces the immediate availability of PHP
7.2.8. This is a security release which also contains several minor bug fixes.
All PHP 7.2 users are encouraged to upgrade to this version.
For source downloads of PHP 7.2.8 please visit our ,
Windows source and binaries can be found on .
The list of changes is recorded in the .
19 Jul 2018
The PHP team is glad to announce the release of the fourth PHP 7.3.0 version, PHP 7.3.0alpha4.
The rough outline of the PHP 7.3 release cycle is specified in the
For source downloads of PHP 7.3.0alpha4 please visit the .
Windows sources and binaries can be found on .
Please carefully test this version and report any issues found in the .
THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION!
For more information on the new features and other changes, you can read the
file for a complete list of upgrading notes. These files can also be found in the release archive.
The next release would be Beta 1, planned for August 2nd.
The signatures for the release can be found in
Thank you for helping us make PHP better.
05 Jul 2018
The PHP team is glad to announce the release of the third PHP 7.3.0 version, PHP 7.3.0 Alpha 3.
The rough outline of the PHP 7.3 release cycle is specified in the
For source downloads of PHP 7.3.0 Alpha 3 please visit the .
Windows sources and binaries can be found on .
Please carefully test this version and report any issues found in the .
THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION!
For more information on the new features and other changes, you can read the
file for a complete list of upgrading notes. These files can also be found in the release archive.
The next release would be Beta 1, planned for July 19th.
The signatures for the release can be found in
Thank you for helping us make PHP better.
25 Jun 2018
The PHP development team announces the immediate availability of PHP
All PHP 7.1 users are encouraged to upgrade to this version.
For source downloads of PHP 7.1.19 please visit our ,
Windows source and binaries can be found on .
The list of changes is recorded in the .
21 Jun 2018
The PHP development team announces the immediate availability of PHP 7.2.7.
This is a primarily a bugfix release which includes a segfault fix for opcache.
PHP 7.2 users are encouraged to upgrade to this version.
For source downloads of PHP 7.2.7 please visit our ,
Windows source and binaries can be found on .
The list of changes is recorded in the .
21 Jun 2018
The PHP team is glad to announce the release of the second PHP 7.3.0 version, PHP 7.3.0 Alpha 2.
The rough outline of the PHP 7.3 release cycle is specified in the
For source downloads of PHP 7.3.0 Alpha 2 please visit the .
Windows sources and binaries can be found on .
Please carefully test this version and report any issues found in the .
THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION!
For more information on the new features and other changes, you can read the
file for a complete list of upgrading notes. These files can also be found in the release archive.
The next release would be Alpha 3, planned for July 5.
The signatures for the release can be found in
Thank you for helping us make PHP better.
07 Jun 2018
PHP team is glad to announce the release of the first PHP 7.3.0 version, PHP 7.3.0 Alpha 1.
This starts the PHP 7.3 release cycle, the rough outline of which is specified in the
For source downloads of PHP 7.3.0 Alpha 1 please visit the .
Please carefully test this version and report any issues found in the .
Please DO NOT use this version in production, it is an early test version.
For more information on the new features and other changes, you can read the
file for a complete list of upgrading notes. These files can also be found in the release archive.
The next release would be Alpha 2, planned for June 21.
The signatures for the release can be found in
Thank you for helping us make PHP better.
01 Feb 2018
The PHP development team announces the immediate availability of PHP
7.2.2. This is a bugfix release, with several bug fixes included.
All PHP 7.2 users are encouraged to upgrade to this version.
For source downloads of PHP 7.2.2 please visit our ,
Windows source and binaries can be found on .
The list of changes is recorded in the .
12 Oct 2017
The PHP development team announces the immediate availability of PHP 7.2.0 RC4.
This release is the fourth Release Candidate for 7.2.0.
All users of PHP are encouraged to test this version carefully, and report any bugs
and incompatibilities in the .
THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION!
For more information on the new features and other changes, you can read the
file for a complete list of upgrading notes. These files can also be found in the release archive.
For source downloads of PHP 7.2.0 Release Candidate 4 please visit the
Windows sources and binaries can be found at
The next Release Candidate will be announced on the 26th of October.
You can also read the full list of planned releases on
Thank you for helping us make PHP better.
28 Sep 2017
The PHP development team announces the immediate availability of PHP 7.2.0 RC3.
This release is the third Release Candidate for 7.2.0.
All users of PHP are encouraged to test this version carefully, and report any bugs
and incompatibilities in the .
THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION!
For more information on the new features and other changes, you can read the
file for a complete list of upgrading notes. These files can also be found in the release archive.
For source downloads of PHP 7.2.0 Release Candidate 3 please visit the
Windows sources and binaries can be found at
The next Release Candidate will be announced on the 12th of October.
You can also read the full list of planned releases on
Thank you for helping us make PHP better.
31 Aug 2017
The PHP development team announces the immediate availability of PHP 7.2.0 Release
Candidate 1. This release is the first Release Candidate for 7.2.0.
All users of PHP are encouraged to test this version carefully, and report any bugs
and incompatibilities in the .
THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION!
For more information on the new features and other changes, you can read the
file for a complete list of upgrading notes. These files can also be found in the release archive.
For source downloads of PHP 7.2.0 Release Candidate 1 please visit the
Windows sources and binaries can be found at
The second Release Candidate will be released on the 14th of September.
You can also read the full list of planned releases on
Thank you for helping us make PHP better.
17 Aug 2017
The PHP development team announces the immediate availability of PHP 7.2.0 Beta 3.
This release is the third and final beta for 7.2.0. All users of PHP are encouraged
to test this version carefully, and report any bugs and incompatibilities in the
THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION!
For more information on the new features and other changes, you can read the
file for a complete list of upgrading notes. These files can also be found in the release archive.
For source downloads of PHP 7.2.0 Beta 3 please visit the
Windows sources and binaries can be found at
The first Release Candidate will be released on the 31th of August.
You can also read the full list of planned releases on
Thank you for helping us make PHP better.
06 Jul 2017
The PHP development team announces the immediate availability of PHP 7.2.0 Alpha 3.
This release contains fixes and improvements relative to Alpha 2.
All users of PHP are encouraged to test this version carefully,
and report any bugs and incompatibilities in the
THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION!
For information on new features and other changes, you can read the
for a complete list of upgrading notes. These files can also be found in the release archive.
For source downloads of PHP 7.2.0 Alpha 3 please visit the
Windows sources and binaries can be found on .
The first beta will be released on the 20th of July. You can also read the full list of planned releases on our
Thank you for helping us make PHP better.&p&提一个&b&双指针&/b&思想,可以巧妙地解决很多链表相关的问题。举两个Leetcode上的例子:&/p&&h2&从链表中移除倒数第n个节点&/h2&&a href=&//link.zhihu.com/?target=https%3A//leetcode.com/problems/remove-nth-node-from-end-of-list/description/& data-draft-node=&block& data-draft-type=&link-card& data-image=&https://pic1.zhimg.com/v2-0c435ab948b151fd834be55f80a0.jpg& data-image-width=&500& data-image-height=&260& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&Remove Nth Node From End of List - LeetCode&/a&&figure&&img src=&https://pic4.zhimg.com/50/v2-83bd844caec3e24dda0c1_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&882& data-rawheight=&466& class=&origin_image zh-lightbox-thumb& width=&882& data-original=&https://pic4.zhimg.com/50/v2-83bd844caec3e24dda0c1_r.jpg&&&/figure&&p&双指针解法:使用两个指针,第一个指针从链表的第n + 1个节点前进,而第二个指针从列表的开始处前进。这样两个指针相距n个节点,两个指针一块前进,这样当第一个指针到达最后一个节点时,第二个指针指向倒数第n+1个节点,接下来就可以直接移除倒数第n个节点了。时间复杂度O(L),空间复杂度O(1)。看图会更直观:&/p&&figure&&img src=&https://pic4.zhimg.com/50/v2-bfa4c5faeacf9f3c984b9acc9d306a46_b.jpg& data-caption=&& data-size=&small& data-rawwidth=&746& data-rawheight=&800& class=&origin_image zh-lightbox-thumb& width=&746& data-original=&https://pic4.zhimg.com/50/v2-bfa4c5faeacf9f3c984b9acc9d306a46_r.jpg&&&/figure&&h2&判断链表是否有环&/h2&&a href=&//link.zhihu.com/?target=https%3A//leetcode.com/problems/linked-list-cycle/description/& data-draft-node=&block& data-draft-type=&link-card& data-image=&https://pic1.zhimg.com/v2-0c435ab948b151fd834be55f80a0.jpg& data-image-width=&500& data-image-height=&260& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&Linked List Cycle - LeetCode&/a&&figure&&img src=&https://pic3.zhimg.com/50/v2-62d185c165cfe_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&805& data-rawheight=&432& class=&origin_image zh-lightbox-thumb& width=&805& data-original=&https://pic3.zhimg.com/50/v2-62d185c165cfe_r.jpg&&&/figure&&p&双指针解法:使用一个快指针(一次前进两个节点)和一个慢指针(一次前进一个节点),两个指针同时从头结点出发,如果链表存在环,那么两个指针一定会相遇。时间复杂度O(n),空间复杂度O(1)。&/p&&p&(这题也能用一个指针加Hash Table解决,即判断指针当前节点之前是否已经遍历过,但空间复杂度就是O(n))&/p&&p&更多双指针解题的例子可以见这篇博文:&/p&&a href=&//link.zhihu.com/?target=https%3A//www.cnblogs.com/byrhuangqiang/p/4708608.html& data-draft-node=&block& data-draft-type=&link-card& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&Leetcode解题思想总结篇:双指针 - BYRHuangQiang - 博客园&/a&&p&最近刷Leetcode的过程中,经常是绞尽脑汁想出一个解法,然后翻leetcode的Solution总能看到复杂度好很多的解法,刷题路漫漫啊。&/p&
提一个双指针思想,可以巧妙地解决很多链表相关的问题。举两个Leetcode上的例子:从链表中移除倒数第n个节点双指针解法:使用两个指针,第一个指针从链表的第n + 1个节点前进,而第二个指针从列表的开始处前进…
&figure&&img src=&https://pic4.zhimg.com/v2-fd9daee82af8d042a597327d_b.jpg& data-rawwidth=&1000& data-rawheight=&667& class=&origin_image zh-lightbox-thumb& width=&1000& data-original=&https://pic4.zhimg.com/v2-fd9daee82af8d042a597327d_r.jpg&&&/figure&&p&有很多朋友问我,想自学编程,零基础,有什么书推荐吗?&/p&&p&&br&&/p&&p&所以我花时间整理了一下目前主流的三大编程语言C、Java、Python学习的经典教材,从入门到进阶,各个阶段的书籍都有。&/p&&p&&br&&/p&&h2&&b&C语言&/b&&/h2&&p&&br&&/p&&h2&1 &b&The Design and Evolution of C++&/b&&/h2&&ul&&li&首先肯定要读一读Bjarne Stroustrup的The Design and Evolution of C++,了解&br&一下这个语言的历史。接下来就可以看别的书了,但要不停地回头看这本书,看到你不断地学到的新技术是怎么样一点点地被接纳到这个语言中去的。&/li&&/ul&&h2&2 &b&C++ Primer&/b&&/h2&&ul&&li&第一本书因人而异,基础好一些的,可以看Stanley B. Lippman的C++ Primer,这本书非常地巨大,你打星号的部分可以不要看。基础不太好的,可以看Stanley B.Lippman的Essential C++,这本书份量要轻得多,不过四个C++的范型都讲了,而且讲得非常清楚。&/li&&/ul&&h2&3 &b&Thinking in C++&/b&&/h2&&ul&&li&第二本书,就应该是Bruce Eckel写的、候捷译的Thinking in C++,这本书技术运用的非常高的境界,但是语言非常平实,只要认真地读,即使基础不行,也一定可以懂。&/li&&/ul&&h2&4 &b&Effective C++和More Effective C++&/b&&/h2&&ul&&li&第三本应该静下心来看看Scott Meyers的Effective C++和More Effective C++,好好地整理一下,在程序设计中应该有哪些注意的事项。可以指导项目运作了,可以编写一切你想做的程序了,可以指出别人看起来不错的代码的大小问题了&/li&&/ul&&p&&br&&/p&&h2&&b&Java&/b&&/h2&&p&&b&Java基础&/b&&/p&&p&1 &b&Java编程思想(第4版)&/b&&/p&&ul&&li&本书赢得了全球程序员的广泛赞誉,即使是最晦涩的概念,在Bruce Eckel的文字亲和力和小而直接的编程示例面前也会化解于无形。从Java的基础语法到最高级特性(深入的面向对象概念、多线程、自动项目构建、单元测试和调试等),本书都能逐步指导你轻松掌握.&/li&&/ul&&p&2 &b&Java核心技术 卷Ⅰ 基础知识(第8版)&/b&&/p&&ul&&li&这本书在Java领域是和Java编程思想齐名的一本书,很多知识点都讲的特别细,我初次看的时候发现课上好多没讲的基础知识这本书上都提到了,非常有助于你练好扎实的基础知识。&/li&&/ul&&p&&br&&/p&&p&&b&Java中级&/b&&/p&&p&1 &b&大话设计模式&/b&&/p&&ul&&li&设计模式体现的是一种思想,思想是指导行为的一切。理解和掌握设计模式,记住23种或者更多的设计场景和解决策略是不够的,更要接受一种思想的熏陶和洗礼。&/li&&li&本书通过故事讲述程序如何设计。希望能给渴望了解面向对象程序设计的初学者及困惑、无法复用的代码编程体验者一些好的建议和提示。&/li&&/ul&&p&2 &b&分布式Java应用基础与实践&/b&&/p&&ul&&li&本书介绍分布式Java应用涉及的知识点,分为基于Java实现网络通信、RPC;基于SOA实现大型分布式Java应用;编写高性能Java应用;构建高可用、可伸缩的系统四个部分,共七章内容。&/li&&/ul&&p&3 &b&Java并发编程实践&/b&&/p&&ul&&li&《JAVA并发编程实践》随着多核处理器的普及,使用并发成为构建高性能应用程序的关键。Java 5以及6在开发并发程序中取得了显著的进步,提高了Java虚拟机的性能以及并发类的可伸缩性,并加入了丰富的新并发构建块。在《JAVA并发编程实践》中,这些便利工具的创造者不仅解释了它们究竟如何工作、如何使用,还阐释了创造它们的原因,及其背后的设计模式。&/li&&/ul&&p&&br&&/p&&p&&b&Java高级&/b&&/p&&p&1&b&大型网站技术架构:核心原理与案例分析&/b&&/p&&ul&&li&该书通过梳理大型网站技术发展历程,剖析大型网站技术架构模式,深入讲述大型互联网架构设计的核心原理。&/li&&/ul&&p&2 &b&代码整洁之道&/b&&/p&&ul&&li&这本书重在对细节的关注。书的编排极其合理,从最小的点开始一点点往大处讲。感觉对刚开始工作的小朋友们,代码看得、写得还不够多,读设计模式之类的书可能还没什么体会。但这本代码细节的书,却是能立竿见影,直接用到工作中去的。&/li&&/ul&&p&&br&&/p&&h2&&b&Python&/b&&/h2&&h2&&b&1 Python核心编程(第二版)&/b&&/h2&&ul&&li&本书是经典的Python[1] 指导书,在第一版的基础上进行了全面升级。全书分为两个部分:第1部分占据了大约三分之二的篇幅,阐释这门语言的“核心”内容,包括基本的概念和语句、语法和风格、Python对象、数字类型、序列类型、映射和集合类型、条件和循环、文件和输入/输出、错误和异常、函数和函数式编程、模块、面向对象编程、执行环境等内容:第2部分则提供了各种高级主题来展示可以使用Python做些什么,包括正则表达式、网络编程、网络客户端编程、多线程编程、图形用户界面编程、Web编程、数据库编程、扩展Python 和一些其他材料。&/li&&/ul&&h2&2 &b&Python高级编程&/b&&/h2&&ul&&li&《Python高级编程》针对具备一定Python基础并希望通过在项目中应用最佳实践和新的开发技术来提升自己的Python开发人员。&/li&&/ul&&h2&3 &b&Python数据结构与算法&/b&&/h2&&ul&&li&主要是介绍了如何使用Python实现常用的一些数据结构,例如堆栈、队列、二叉树等等。&/li&&/ul&&h2&4 &b&利用Python进行数据分析&/b&&/h2&&ul&&li&从pandas库的数据分析工具开始利用高性能工具对数据进行加载、清理、转换、合并以及重塑;利用matpIotlib创建散点图以及静态或交互式的可视化结果;利用pandas的groupby功能对数据集进行切片、切块和汇总操作;处理各种各样的时间序列数据。&/li&&/ul&&p&&br&&/p&&p&&b&获取方式很简单,没有任何套路,在我的公众号【Programmer-ing】后台回复【图书】就可以免费获取这份大礼包了~&/b&&/p&&p&&br&&/p&&p&其实我收藏的计算机专业方面的书籍挺多的,以下是截图:&/p&&figure&&img src=&https://pic4.zhimg.com/v2-6eaa41b4693f2cda1b309f72acf6c0bd_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&1366& data-rawheight=&768& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&https://pic4.zhimg.com/v2-6eaa41b4693f2cda1b309f72acf6c0bd_r.jpg&&&/figure&&p&等我以后有时间了,也整理出来送给大家,供大家学习与交流,如果你有什么问题想要交流,或者想要其它的书籍和资源的话,可以加我微信:build_wheels,我拉你进群,然后我要是有相应资源的话会在群里分享给大家,添加我的时候请备注“加群”。&/p&&p&&br&&/p&&p&&b&如果觉得不错,好东西不该私藏,希望大家随手点赞,帮忙转发扩散给更多人,当然如果你愿意赞赏支持我一下,我会很开心的,谢谢大家。&/b&&/p&
有很多朋友问我,想自学编程,零基础,有什么书推荐吗? 所以我花时间整理了一下目前主流的三大编程语言C、Java、Python学习的经典教材,从入门到进阶,各个阶段的书籍都有。 C语言 1 The Design and Evolution of C++首先肯定要读一读Bjarne Stroustrup的T…
&p&打算做出一个目录集合,将我做过的有意思的适合新人练手的Python小项目在此保持长期更新。(最新的项目置顶)&/p&&p&&b&github:&a href=&//link.zhihu.com/?target=https%3A//github.com/Flowingsun007/littleSpiders& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&Flowingsun007/littleSpiders&/a&
求点赞+点Star!!! 谢谢:)&/b&&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon:Python图片文本识别—基于tesseract和百度实现&/a& (更新于18.4.15)&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon: Python实现微信查天气+火车+飞机+快递&/a&
(更新于18.3.7)&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon:Python—itchat下载拼接微信好友头像图&/a& (更新于18.3.6)&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon:Python—itchat实现微信自动回复&/a&(更新于18.3.5)&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon: Python命令行实现—查全国7天天气&/a&&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon: Python命令行查询12306火车票&/a& (更新于18.2.19)&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon: Python—一行代码情人节画爱心表白&/a& (更新于18.2.14)&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon: Python多线程threading—图片下载&/a& (更新于18.2.5)&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon:Python—10行代码查快递&/a& (更新于18.2.2)&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon:用Python发邮件&/a&(更新于18.1.23)&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon:Python爬虫入门—图片下载&/a&&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon:用Python实现—携程机票查询&/a&&/p&&p&&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&Lyon:智联Python相关职位的数据分析及可视化-Pandas&Matplotlib篇&/a&&/p&&hr&&a href=&https://zhuanlan.zhihu.com/p/& data-draft-node=&block& data-draft-type=&link-card& data-image=&https://pic4.zhimg.com/v2-52f03c10c60f827acdcfa7_180x120.jpg& data-image-width=&4808& data-image-height=&3205& class=&internal&&Lyon:Python—一行代码情人节画爱心表白&/a&&p&情人节快到了,怎么表白?受到&a href=&https://zhuanlan.zhihu.com/p/& class=&internal&&几个小例子告诉你, 一行Python代码能干哪些事&/a&&/p&&p&的启发,我决定用Python写一段? 的话来表白(装X)。原文是一行代码实现输出爱心图:&/p&&div class=&highlight&&&pre&&code class=&language-text&&print('\n'.join([''.join([('Love'[(x-y) % len('Love')] if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 &= 0 else ' ') for x in range(-30, 30)]) for y in range(30, -30, -1)]))
&/code&&/pre&&/div&&p&效果如下:&/p&&figure&&img src=&https://pic2.zhimg.com/50/v2-08e7c9e605de8fff001bd9cc11fbd1f7_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&590& data-rawheight=&473& class=&origin_image zh-lightbox-thumb& width=&590& data-original=&https://pic2.zhimg.com/50/v2-08e7c9e605de8fff001bd9cc11fbd1f7_r.jpg&&&/figure&&p&但是,有点太单调了点,来,让我撸起袖子搞点事情,将代码简单改造一下,实现动态输出心形的一段话的效果:&/p&&p&改造以后,看上去不错了!效果如下:&/p&&a class=&video-box& href=&//link.zhihu.com/?target=https%3A//www.zhihu.com/video/270656& target=&_blank& data-video-id=&& data-video-playable=&true& data-name=&& data-poster=&https://pic3.zhimg.com/80/v2-0f334a2dec425d82d4aa_b.jpg& data-lens-id=&270656&&
&img class=&thumbnail& src=&https://pic3.zhimg.com/80/v2-0f334a2dec425d82d4aa_b.jpg&&&span class=&content&&
&span class=&title&&&span class=&z-ico-extern-gray&&&/span&&span class=&z-ico-extern-blue&&&/span&&/span&
&span class=&url&&&span class=&z-ico-video&&&/span&https://www.zhihu.com/video/270656&/span&
&/a&&p&代码如下,喜欢请点赞哦,谢谢?!:&/p&&div class=&highlight&&&pre&&code class=&language-text&&import time
words = input('Please input the words you want to say!:')
for item in words.split():
print('\n'.join([''.join([(item[(x-y) % len(item)] if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 &= 0 else ' ') for x in range(-30, 30)]) for y in range(12, -12, -1)]))
time.sleep(1.5);
&/code&&/pre&&/div&&p&其实,像?
这样类型的颜文字其实也是可以输出的,不过格式不是标准的心型,需要自行调节,大家可以自己尝试下^_^!&/p&&hr&&a href=&https://zhuanlan.zhihu.com/p/& data-draft-node=&block& data-draft-type=&link-card& data-image=&https://pic4.zhimg.com/v2-1b53dea4af_180x120.jpg& data-image-width=&1920& data-image-height=&1080& class=&internal&&Lyon:用Python发邮件&/a&&p&本次,我们发邮件用到的Python库是smtplib和email。简单来说,smtplib库主要是用于负责和邮件服务器进行通讯,email库则主要用于规定编写邮件的头、主体、内容、附件等。&/p&&p&发邮件之前我们需要用Python登录smtp服务器,这样才能有发送权限,所以,我们需要去邮箱手动开启smtp服务,然后记住服务器授权码(授权码意思是,你可以不用我的网页邮箱或者邮箱app登录,你可以用邮箱账号+授权码在后台来获取邮箱服务器的内容)&/p&&figure&&img src=&https://pic3.zhimg.com/50/v2-d2aa32b22ebd670cda6878e_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&1148& data-rawheight=&568& class=&origin_image zh-lightbox-thumb& width=&1148& data-original=&https://pic3.zhimg.com/50/v2-d2aa32b22ebd670cda6878e_r.jpg&&&/figure&&p&由于本次我们用QQ邮箱发送,你也可以用网易邮箱或者其他邮箱发送,原理都是类似~&/p&&p&&b&如何开启QQ邮箱smtp服务器和获取授权码:&/b&&/p&&p&&a href=&//link.zhihu.com/?target=https%3A//jingyan.baidu.com/article/fedf5ac8977ea.html& class=& external& target=&_blank& rel=&nofollow noreferrer&&&span class=&invisible&&https://&/span&&span class=&visible&&jingyan.baidu.com/artic&/span&&span class=&invisible&&le/fedf5ac8977ea.html&/span&&span class=&ellipsis&&&/span&&/a&&/p&&p&很多场合都会用到邮箱授权码进行邮件的收取,现在讲一下如何QQ邮箱的授权码获取方式,网易邮箱的也差不多哦~&/p&&p&&br&&/p&&hr&&p&获取好服务器授权码后,我们就可以写代码了,本次发送一个简单的文字邮件,然后添加一张可爱猪的图片作为附件:&/p&&figure&&img src=&https://pic1.zhimg.com/50/v2-4be759e29a16afd43cf807_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&519& data-rawheight=&352& class=&origin_image zh-lightbox-thumb& width=&519& data-original=&https://pic1.zhimg.com/50/v2-4be759e29a16afd43cf807_r.jpg&&&/figure&&p&程序运行结果:&/p&&figure&&img src=&https://pic3.zhimg.com/50/v2-eeeed16a14dc_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&1187& data-rawheight=&694& class=&origin_image zh-lightbox-thumb& width=&1187& data-original=&https://pic3.zhimg.com/50/v2-eeeed16a14dc_r.jpg&&&/figure&&p&代码如下:&/p&&p&&code&import smtplib&br&from email import encoders&br&from email.mime.text import MIMEText&br&from email.mime.base import MIMEBase&br&from email.mime.multipart import MIMEMultipart&br&#sender是邮件发送人邮箱,passWord是服务器授权码,mail_host是服务器地址(这里是QQsmtp服务器)&br&sender = ''#&br&passWord = 'xxx'&br&mail_host = 'smtp.qq.com'&br&#receivers是邮件接收人,用列表保存,可以添加多个&br&receivers = ['','']&br&&br&#设置email信息&br&msg = MIMEMultipart()&br&#邮件主题&br&msg['Subject'] = input(f&{'请输入邮件主题:'}&)&br&#发送方信息&br&msg['From'] = sender&br&#邮件正文是MIMEText:&br&msg_content = input(f&{'请输入邮件主内容:'}&)&br&msg.attach(MIMEText(msg_content, 'plain', 'utf-8'))&br&# 添加附件就是加上一个MIMEBase,从本地读取一个图片:&br&with open('/Users/xxx/1.jpg', 'rb') as f:&br&
# 设置附件的MIME和文件名,这里是jpg类型,可以换png或其他类型:&br&
mime = MIMEBase('image', 'jpg', filename='Lyon.png')&br&
# 加上必要的头信息:&br&
mime.add_header('Content-Disposition', 'attachment', filename='Lyon.png')&br&
mime.add_header('Content-ID', '&0&')&br&
mime.add_header('X-Attachment-Id', '0')&br&
# 把附件的内容读进来:&br&
mime.set_payload(f.read())&br&
# 用Base64编码:&br&
encoders.encode_base64(mime)&br&
# 添加到MIMEMultipart:&br&
msg.attach(mime)&br&&br&#登录并发送邮件&br&try:&br&
#QQsmtp服务器的端口号为465或587&br&
s = smtplib.SMTP_SSL(&http://smtp.qq.com&, 465)&br&
s.set_debuglevel(1)&br&
s.login(sender,passWord)&br&
#给receivers列表中的联系人逐个发送邮件&br&
for i in range(len(receivers)):&br&
to = receivers[i]&br&
msg['To'] = to&br&
s.sendmail(sender,to,msg.as_string())&br&
print('Success!')&br&
s.quit()&br&
print (&All emails have been sent over!&)&br&except smtplib.SMTPException as e:&br&
print (&Falied,%s&,e)&/code& &/p&&hr&&p&更新:没想到,会火,40000+关注的问题果然流量够大~&/p&&p&再增加一个Python爬图片,下载到本地的小项目!&/p&&a href=&https://zhuanlan.zhihu.com/p/& data-draft-node=&block& data-draft-type=&link-card& data-image=&https://pic2.zhimg.com/v2-a7dec1d74d10x120.jpg& data-image-width=&1920& data-image-height=&1080& class=&internal&&Lyon:Python爬虫入门—图片下载&/a&&hr&&p&这次决定写一个爬虫程序来爬精美的壁纸图,壁纸网站看了知乎网友的推荐,选择的是:&/p&&a href=&//link.zhihu.com/?target=https%3A//alpha.wallhaven.cc/& data-draft-node=&block& data-draft-type=&link-card& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&Awesome Wallpapers - wallhaven.cc&/a&&figure&&img src=&https://pic2.zhimg.com/50/v2-9d188f6abcbb6faf83f4dcce3541dec9_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&921& data-rawheight=&636& class=&origin_image zh-lightbox-thumb& width=&921& data-original=&https://pic2.zhimg.com/50/v2-9d188f6abcbb6faf83f4dcce3541dec9_r.jpg&&&/figure&&p&此程序支持输入关键词,根据查询结果返回图片总数、然后在本地新建文件夹、字典下载图片到文件夹中。&/p&&p&效果如下:&/p&&figure&&img src=&https://pic3.zhimg.com/50/v2-1a66eb8d67ff7eceeaaee1_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&1085& data-rawheight=&696& class=&origin_image zh-lightbox-thumb& width=&1085& data-original=&https://pic3.zhimg.com/50/v2-1a66eb8d67ff7eceeaaee1_r.jpg&&&/figure&&p&代码如下:&/p&&div class=&highlight&&&pre&&code class=&language-text&&#_*_ coding:utf-8 _* _
#__author__='阳光流淌007'
#__date__=''
#爬取wallhaven上的的图片,支持自定义搜索关键词,自动爬取并该关键词下所有图片并存入本地电脑。
import requests
import time
import random
from lxml import etree
keyWord = input('Please input the keywords that you want to download :')
class Spider():
#初始化参数
def __init__(self):
#headers是请求头,&User-Agent&、&Accept&等字段都是通过谷歌Chrome浏览器查找的!
self.headers = {
&User-Agent&: &Mozilla/5.0 (M Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0. Safari/537.36&,
#filePath是自定义的,本次程序运行后创建的文件夹路径,存放各种需要下载的对象。
self.filePath = ('/users/zhaoluyang/小Python程序集合/桌面壁纸/'+ keyWord + '/')
def creat_File(self):
#新建本地的文件夹路径,用于存储网页、图片等数据!
filePath = self.filePath
if not os.path.exists(filePath):
os.makedirs(filePath)
def get_pageNum(self):
#用来获取搜索关键词得到的结果总页面数,用totalPagenum记录。由于数字是夹在形如:1,985 Wallpapers found for “dog”的string中,
#所以需要用个小函数,提取字符串中的数字保存到列表numlist中,再逐个拼接成完整数字。。。
total = &&
url = (&https://alpha.wallhaven.cc/search?q={}&categories=111&purity=100&sorting=relevance&order=desc&).format(keyWord)
html = requests.get(url)
selector = etree.HTML(html.text)
pageInfo = selector.xpath('//header[@class=&listing-header&]/h1[1]/text()')
string = str(pageInfo[0])
numlist = list(filter(str.isdigit,string))
for item in numlist:
total += item
totalPagenum = int(total)
return totalPagenum
def main_fuction(self):
#count是总图片数,times是总页面数
self.creat_File()
count = self.get_pageNum()
print(&We have found:{} images!&.format(count))
times = int(count/24 + 1)
for i in range(times):
pic_Urls = self.getLinks(i+1)
for item in pic_Urls:
self.download(item,j)
def getLinks(self,number):
#此函数可以获取给定numvber的页面中所有图片的链接,用List形式返回
url = (&https://alpha.wallhaven.cc/search?q={}&categories=111&purity=100&sorting=relevance&order=desc&page={}&).format(keyWord,number)
html = requests.get(url)
selector = etree.HTML(html.text)
pic_Linklist = selector.xpath('//a[@class=&jsAnchor thumb-tags-toggle tagged&]/@href')
except Exception as e:
print(repr(e))
return pic_Linklist
def download(self,url,count):
#此函数用于图片下载。其中参数url是形如:https://alpha.wallhaven.cc/wallpaper/616442/thumbTags的网址
#616442是图片编号,我们需要用strip()得到此编号,然后构造html,html是图片的最终直接下载网址。
string = url.strip('/thumbTags').strip('https://alpha.wallhaven.cc/wallpaper/')
html = 'http://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-' + string + '.jpg'
pic_path = (self.filePath + keyWord + str(count) + '.jpg' )
pic = requests.get(html,headers = self.headers)
f = open(pic_path,'wb')
f.write(pic.content)
print(&Image:{} has been downloaded!&.format(count))
time.sleep(random.uniform(0,2))
except Exception as e:
print(repr(e))
spider = Spider()
spider.main_fuction()
&/code&&/pre&&/div&&figure&&img src=&https://pic1.zhimg.com/50/v2-1bcdcb41eacc8ab_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&1920& data-rawheight=&1200& class=&origin_image zh-lightbox-thumb& width=&1920& data-original=&https://pic1.zhimg.com/50/v2-1bcdcb41eacc8ab_r.jpg&&&/figure&&figure&&img src=&https://pic2.zhimg.com/50/v2-82b93a0dbca8b5fea23c_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&6016& data-rawheight=&4000& class=&origin_image zh-lightbox-thumb& width=&6016& data-original=&https://pic2.zhimg.com/50/v2-82b93a0dbca8b5fea23c_r.jpg&&&/figure&&p&注意:&/p&&p&图片虽好,可是下载速度挺慢的,可能和网站服务器有关~没有验证过网站是否有反爬虫机制,加了time.sleep(random.uniform(0,2))让图片下载完后停顿0~2秒,1来防止给服务器带来过大压力,2来也怕被爬虫机制检测~&/p&&hr&&a href=&https://zhuanlan.zhihu.com/p/& data-draft-node=&block& data-draft-type=&link-card& data-image=&https://pic3.zhimg.com/v2-b8fd8a32f0dfab58b37e386_180x120.jpg& data-image-width=&872& data-image-height=&604& class=&internal&&Lyon:用Python实现—携程机票查询&/a&&p&以前参考别人的代码,用Python做了一个12306命令行式的火车票查询工具,感觉还挺有意思的!于是自己又做了一个类似的——携程机票查询器。&/p&&p&携程官网查询的效果是这样的:&/p&&figure&&img src=&https://pic3.zhimg.com/50/v2-89f157c0a8bd7d891fa44_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&1190& data-rawheight=&874& class=&origin_image zh-lightbox-thumb& width=&1190& data-original=&https://pic3.zhimg.com/50/v2-89f157c0a8bd7d891fa44_r.jpg&&&/figure&&p&Python命令行界面查询的效果是这样的:&/p&&figure&&img src=&https://pic3.zhimg.com/50/v2-b8fd8a32f0dfab58b37e386_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&872& data-rawheight=&604& class=&origin_image zh-lightbox-thumb& width=&872& data-original=&https://pic3.zhimg.com/50/v2-b8fd8a32f0dfab58b37e386_r.jpg&&&/figure&&p&输入出发地、目的地、乘机日期,即可看到可选的航班、机场、出发到达时间、票价等信息。&/p&&p&视频演示效果如下:&/p&&a class=&video-box& href=&//link.zhihu.com/?target=https%3A//www.zhihu.com/video/787776& target=&_blank& data-video-id=&& data-video-playable=&true& data-name=&& data-poster=&https://pic2.zhimg.com/80/v2-029a73d6a55f5a1c9ed8d56c1c84f71d_b.jpg& data-lens-id=&787776&&
&img class=&thumbnail& src=&https://pic2.zhimg.com/80/v2-029a73d6a55f5a1c9ed8d56c1c84f71d_b.jpg&&&span class=&content&&
&span class=&title&&&span class=&z-ico-extern-gray&&&/span&&span class=&z-ico-extern-blue&&&/span&&/span&
&span class=&url&&&span class=&z-ico-video&&&/span&https://www.zhihu.com/video/787776&/span&
&/a&&p&程序的源码如下:&/p&&p&1.air_stations.py&/p&&p&2.airline_ticket.py&/p&&div class=&highlight&&&pre&&code class=&language-text&&#1.air_stations.py
import json
import requests
from pprint import pprint
url = 'http://webresource.c-ctrip.com/code/cquery/resource/address/flight/flight_new_poi_gb2312.js?CR__00_00_00'
response = requests.get(url,verify=False)
station = re.findall(u'([\u4e00-\u9fa5]+)\(([A-Z]+)\)', response.text)
stations = dict(station)
pprint(stations,indent = 4)
&/code&&/pre&&/div&&p&&br&&/p&&div class=&highlight&&&pre&&code class=&language-text&&2.airline_ticket.py
#此程序可用于查询携程机票,查询需要指定出发日期、出发城市、目的城市!(模仿了上一个12306火车订票查询程序)
import requests,json,os
from docopt import docopt
from prettytable import PrettyTable
from colorama import init,Fore
from air_stations import stations
fromCity = input('Please input the city you want leave :')
toCity = input('Please input the city you will arrive :')
tripDate = input('Please input the date(Example:) :')
class TrainsCollection:
header = '航空公司 航班 机场 时间 机票价格 机场建设费'.split()
def __init__(self,airline_tickets):
self.airline_tickets = airline_tickets
def plains(self):
#航空公司的总表没有找到,但是常见航空公司也不是很多就暂时用这个dict{air_company}来收集!
#如果strs没有查询成功,则会返回一个KeyError,表示此dict中未找到目标航空公司,则会用其英文代码显示!
air_company = {&G5&:&华夏航空&,&9C&:&春秋航空&,&MU&:&东方航空&,&NS&:&河北航空&,&HU&:&海南航空&,&HO&:&吉祥航空&,&CZ&:&南方航空&,&FM&:&上海航空&,&ZH&:&深圳航空&,&MF&:&厦门航空&,&CA&:&中国国航&,&KN&:&中国联航&}
for item in self.airline_tickets:
strs = air_company[item['alc']]
except KeyError:
strs = item['alc']
airline_data = [
Fore.BLUE + strs + Fore.RESET,
Fore.BLUE + item['fn'] + Fore.RESET,
'\n'.join([Fore.YELLOW + item['dpbn'] + Fore.RESET,
Fore.CYAN + item['apbn'] + Fore.RESET]),
'\n'.join([Fore.YELLOW + item['dt'] + Fore.RESET,
Fore.CYAN + item['at'] + Fore.RESET]),
item['lp'],
item['tax'],
yield airline_data
def pretty_print(self):
#PrettyTable()用于在屏幕上将查询到的航班信息表逐行打印到终端
pt = PrettyTable()
pt._set_field_names(self.header)
for airline_data in self.plains:
pt.add_row(airline_data)
def doit():
headers = {
&Cookie&:&自定义&,
&User-Agent&: &Mozilla/5.0 (M Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0. Safari/537.36&,
arguments = {
'from':fromCity,
'to':toCity,
'date':tripDate
DCity1 = stations[arguments['from']]
ACity1 = stations[arguments['to']]
DDate1 = arguments['date']
url = (&http://flights.ctrip.com/domesticsearch/search/SearchFirstRouteFlights?DCity1={}&ACity1={}&SearchType=S&DDate1={}&IsNearAirportRecommond=0&LogToken=0dc7fdc123f0a8bfcae95&rk=7.&CK=51BF6E070FF329F1DDD90CEF097B4B86&r=0.&).format(DCity1,ACity1,DDate1)
r = requests.get(url,headers = headers,verify=False)
print(&Some Error shows in requests.get(url)&)
print(url)
airline_tickets = r.json()['fis']
TrainsCollection(airline_tickets).pretty_print()
if __name__ == '__main__':
&/code&&/pre&&/div&&p&其实,此小程序还可以拓展,譬如将查询记录存到本地电脑(txt格式、或者存到数据库里)或者更厉害的还可以设置定时自动查询;还可以设置查询到自动发邮箱提醒;还可以用Python的GUI库将此程序做成桌面软件的形式。。。。&/p&&hr&&a href=&https://zhuanlan.zhihu.com/p/& data-draft-node=&block& data-draft-type=&link-card& data-image=&https://pic1.zhimg.com/v2-131ba26ddec_180x120.jpg& data-image-width=&1266& data-image-height=&737& class=&internal&&Lyon:智联Python相关职位的数据分析及可视化-Pandas&Matplotlib篇&/a&&p&,by—&a href=&//link.zhihu.com/?target=http%3A//localhost%3A8080/Lyon/foreviewSingleBlog%3FId%3D12%23& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&阳光流淌&/a&&/p&&h2&上一篇,我用了Excel对爬虫采集到的智联招聘数据进行了数据分析及可视化,用到软件是Excel, 这一篇,我们打算完全用Python来做同样的事。用到的库有Pandas、Matplotlib。np、pd、plt分别是numpy、pandas、matplotlib.pyplot的常用缩写。&/h2&&p&Numpy(Numerical Python的简称)是Python科学计算的基础包。它提供了以下功能:&/p&&ol&&li&快速高效的多维数组对象ndarray。&/li&&li&用于对数组执行元素级计算以及直接对数组执行数学运算的函数。&/li&&li&用于读写硬盘上基于数组的数据集的工具。&/li&&li&线性代数运算、傅里叶变换,以及随机数生成。&/li&&li&用于将C、C++、Fortran代码集成到Python的工具。&/li&&/ol&&p&除了为Python提供快速的数组处理能力,Numpy在数据分析方面还有另外一个主要作用,即作为在算法之间传递数据的容器。对于数值型数据,Numpy数组在存储和处理数据时要比内置的Python数据结构高效的多。此外,由低级语言(比如C和Fortran)编写的库可以直接操作Numpy数组中的数据,无需进行任何数据复制工作。&br&&/p&&p&Pandas这个名字本身源于panel data(面板数据,这是计量经济学中关于多维结构化数据集的一个术语)以及Python data analysis。pandas提供了使我们能够快速便捷地处理结构化数据的大量数据结构和函数。Pandas中用的最多的是DataFrame,它是一个面向列的二维表结构,且含有行标和列标。pandas兼具numpy高性能的数组计算功能以及电子表格和关系型数据库(如SQL)灵活的数据处理功能。它提供了复杂精细的索引功能,以便更为便捷地完成重塑、切片和切块、聚合以及选取数据子集等操作。&/p&&p&Matplotlib是Python中常用的可视化绘图库,可以通过简单的几行代码生成直方图,功率谱,条形图,错误图,散点图等。Seaborn、ggplot、等诸多Python可视化库均是在此基础上开发的,所以学会matplotlib的基础操作还是很有必要的!它和Ipython结合的很好,提供了一种非常好用的交互式数据绘图环境。绘制的图表也是交互式的,你可以利用绘图窗口中的工具栏放大图表中的某个区域或对整个图表进行平移浏览。&/p&&h2&数据来源:&/h2&&p&Python爬虫爬取了智联招聘关键词:【Python】、全国30个主要城市的搜索结果,总职位条数:18326条(行),其中包括【职位月薪】、【公司链接】、【工作地点】、 【岗位职责描述】等14个字段列,和一个索引列【ZL_Job_id】共计15列。数据存储在本地MySql服务器上,从服务器上导出json格式的文件,再用Python进行数据读取分析和可视化。&/p&&h2&数据简单清洗:&/h2&&p&1.首先在终端中打开输入ipython --pylab。在Ipython的shell界面里导入常用的包numpy、pandas、matplotlib.pyplot。用pandas的read_json()方法读取json文件,并转化为用df命名的DataFrame格式文件。(DataFrame格式是Pandas中非常常用且重要的一种数据存储格式、类似于Mysql和Excel中的表。)&/p&&div class=&highlight&&&pre&&code class=&language-text&&import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_json('/Users/zhaoluyang/Desktop/Python_全国JSON.json')
#查看df的信息
df.columns
&/code&&/pre&&/div&&figure&&img src=&https://pic1.zhimg.com/50/v2-f679fb1c4acba7ebdfbd697a9fedcf10_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&884& data-rawheight=&789& class=&origin_image zh-lightbox-thumb& width=&884& data-original=&https://pic1.zhimg.com/50/v2-f679fb1c4acba7ebdfbd697a9fedcf10_r.jpg&&&/figure&&p&可以看到读取的df格式文件共有15列,18326行,pandas默认分配了索引值从0~18325。还有一点值得注意的:全部的15列都有18326个非空值,因为当初写爬虫代码时设置了, 如果是空值,譬如:有一条招聘信息其中【福利标签】空着没写,那么就用字符串代替,如“found no element”。&/p&&p&2.读取JSON文件时pandas默认分配了从0开始的索引,由于文件'ZL_Job_id'列中自带索引,故将其替换!替换后,用sort_index()给索引重新排列。&/p&&div class=&highlight&&&pre&&code class=&language-text&&df.index = df['ZL_Job_id']#索引列用'ZL_Job_id'列替换。
del(df['ZL_Job_id'])#删除原文件中'ZL_Job_id'列。
df_sort = df.sort_index()#给索引列重新排序。
df = df_sort
df[['工作地点','职位月薪']].head(10)
&/code&&/pre&&/div&&figure&&img src=&https://pic2.zhimg.com/50/v2-0b51bcac2a25a476cc795_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&492& data-rawheight=&286& class=&origin_image zh-lightbox-thumb& width=&492& data-original=&https://pic2.zhimg.com/50/v2-0b51bcac2a25a476cc795_r.jpg&&&/figure&&p&3.下面,将进行【职位月薪】列的分列操作,新增三列【bottom】、【top】、【average】分别存放最低月薪、最高月薪和平均月薪。 其中try语句执行的是绝大多数情况:职位月薪格式如:元/月,为此需要对【职位月薪】列用正则表达式逐个处理,并存放至三个新列中。 处理后bottom = 8000,top = 10000,average = 9000. 其中不同语句用于处理不同的情况,譬如【职位月薪】=‘面议’、‘found no element’等。对于字符形式的‘面议’、‘found no element’ 处理后保持原字符不变,即bottom = top = average = 职位月薪。&br&q1,q2,q3,q4用来统计各个语句执行次数.其中q1统计职位月薪形如‘元/月’的次数;q2统计形如月收入‘10000元/月以下’;q3代表其他情况如‘found no element’,‘面议’的次数;q4统计失败的特殊情况。&/p&&div class=&highlight&&&pre&&code class=&language-text&&import re
df['bottom'] = df['top'] = df['average'] = df['职位月薪']
pattern = re.compile('([0-9]+)')
q1=q2=q3=q4=0
for i in range(len(df['职位月薪'])):
item = df['职位月薪'].iloc[i].strip()
result = re.findall(pattern,item)
if result:
#此语句执行成功则表示result[0],result[1]都存在,即职位月薪形如‘元/月’
df['bottom'].iloc[i],df['top'].iloc[i] = result[0],result[1]
df['average'].iloc[i] = str((int(result[0])+int(result[1]))/2)
#此语句执行成功则表示result[0]存在,result[1]不存在,职位月薪形如‘10000元/月以下’
df['bottom'].iloc[i] = df['top'].iloc[i] = result[0]
df['average'].iloc[i] = str((int(result[0])+int(result[0]))/2)
#此语句执行成功则表示【职位月薪】中并无数字形式存在,可能是‘面议’、‘found no element’
df['bottom'].iloc[i] = df['top'].iloc[i] = df['average'].iloc[i] = item
except Exception as e:
print(q4,item,repr(e))
for i in range(100):#测试一下看看职位月薪和bottom、top是否对的上号
print(df.iloc[i][['职位月薪','bottom','top','average']])#或者df[['职位月薪','bottom','top','average']].iloc[i]也可
df[['职位月薪','bottom','top','average']].head(10)
&/code&&/pre&&/div&&figure&&img src=&https://pic2.zhimg.com/50/v2-f17c93681d3dfae5e4f3_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&595& data-rawheight=&516& class=&origin_image zh-lightbox-thumb& width=&595& data-original=&https://pic2.zhimg.com/50/v2-f17c93681d3dfae5e4f3_r.jpg&&&/figure&&p&经过检查,可以发现【职位月薪】和新增的bottom、top、average列是能对的上。其中形如‘元/月’的有16905条、形如‘10000元以下’的 有61条、'found no element'和'面议'加起来有1360条,总数18326条,可见是正确的。&/p&&p&4.进行【工作地点】列的处理,新增【工作城市】列,将工作地点中如‘苏州-姑苏区’、‘苏州-工业园区’等统统转化为‘苏州’存放在【工作城市】列。&/p&&div class=&highlight&&&pre&&code class=&language-text&&df['工作城市'] = df['工作地点']
pattern2 = re.compile('(.*?)(\-)')
df_city = df['工作地点'].copy()
for i in range(len(df_city)):
item = df_city.iloc[i].strip()
result = re.search(pattern2,item)
if result:
print(result.group(1).strip())
df_city.iloc[i] = result.group(1).strip()
print(item.strip())
df_city.iloc[i] = item.strip()
df['工作城市'] = df_city
df[['工作地点','工作城市']].head(20)
&/code&&/pre&&/div&&figure&&img src=&https://pic2.zhimg.com/50/v2-fbfd69ce7d8dd39ce8ecf23a_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&448& data-rawheight=&451& class=&origin_image zh-lightbox-thumb& width=&448& data-original=&https://pic2.zhimg.com/50/v2-fbfd69ce7d8dd39ce8ecf23a_r.jpg&&&/figure&&p&检查一下,没有错误,可以进行下一步的操作了!&/p&&h2&数据分析和可视化&/h2&&p&从可读性来看,应该是先进行数据清洗,然后进行分析及可视化,但是实际过程中,往往是交织在一起的, 所有下面让我们一步步来,完成所有的清洗、分析和可视化工作。除了具体的公司和职位名称以外,我们还比较关心几个关键词: 平均月薪、工作经验、工作城市、最低学历和岗位职责描述,这里岗位职责描述以后会用python分词做词云图,所以目前筛选出 【平均月薪】、【工作经验】、【工作城市】、【最低学历】这四个标签,这些标签可以两两组合产生各种数据。譬如我想知道各个城市的招聘数量分布情况, 会不会大部分的工作机会都集中在北上广深?是不是北上广深的平均工资也高于其他城市?我想知道Python这个关键词的18000多条招聘数据中 对学历的要求和对工作经验的要求,以及它们分别占比多少?我还想知道平均月薪和工作经验的关系?最低学历和平均月薪的关系? 和上一篇(Execel篇)类似,不同的是,这次我们完全用Python实现同样的操作。&/p&&h2&1.各个城市职位数量及分布&/h2&&p&根据猜想,北上广深,一定占据了Python这个关键词下大部分的工作机会,会不会符合28定律?20%的城市占据了80%的岗位? 有可能!我们先用df.工作城市.value_counts()看一下究竟有多少个城市,以及他们各自有多少条工作数据?&/p&&div class=&highlight&&&pre&&code class=&language-text&&df.工作城市.value_counts()#等价于df['工作城市'].value_counts()
#再用count()来看一下统计出来的城市数量
df.工作城市.value_counts().count()
type(df.工作城市.value_counts())#用type()查看下类型。
&/code&&/pre&&/div&&figure&&img src=&https://pic4.zhimg.com/50/v2-23cf8b0e216e0a9aa76b6_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&448& data-rawheight=&578& class=&origin_image zh-lightbox-thumb& width=&448& data-original=&https://pic4.zhimg.com/50/v2-23cf8b0e216e0a9aa76b6_r.jpg&&&/figure&&p&可以看到,明明设置的是搜索30个城市,怎么变成了40?像延边、珲春、白山。。。。是什么鬼?想了一下,这些城市是搜索关键词城市‘吉林市’时,自动冒出来的;还有95个‘found no element’,是这些职位链接本身就没有填写工作城市,为了避免干扰,要把他们统统替换成空值。用df_工作城市 = df['工作城市'].replace()&/p&&div class=&highlight&&&pre&&code class=&language-text&&#将原来df['工作城市']列中选定的字段替换成空值nan
df_工作城市 = df['工作城市'].replace(['found no element','松原','辽源','珲春','白山','公主岭','白城','延边','四平','通化'],np.nan)
#查看替换后各个城市职位计数
df_工作城市.value_counts()
#查看替换后城市所包含的职位总数;查看替换后的城市数量,是否等于30.
df_工作城市
#将新的[df_工作城市]列添加到df表中,留作备用
df['df_工作城市'] = df_工作城市
&/code&&/pre&&/div&&figure&&img src=&https://pic3.zhimg.com/50/v2-aceb11ca737afb_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&828& data-rawheight=&718& class=&origin_image zh-lightbox-thumb& width=&828& data-original=&https://pic3.zhimg.com/50/v2-aceb11ca737afb_r.jpg&&&/figure&&p&看了一下,没有问题,现在df_工作城市中筛选出了30个城市,合计18211条职位数据。 为了数据完整性,df表保持原样,我们用df_工作城市直接操作,进行下一步的可视化。先直接上代码和图,再一一解释下。&/p&&div class=&highlight&&&pre&&code class=&language-text&&fig1 = plt.figure(1,facecolor = 'black')#设置视图画布1
ax1 = fig1.add_subplot(2,1,1,facecolor='#4f4f4f',alpha=0.3)#在视图1中设置子图1,背景色灰色,透明度0.3(figure.add_subplot 和plt.suplot都行)
plt.tick_params(colors='white')#设置轴的颜色为白色
df_工作城市.value_counts().plot(kind='bar',rot=0,color='#ef9d9a')#画直方图图
#设置图标题,x和y轴标题
title = plt.title('城市——职位数分布图',fontsize=18,color='yellow')#设置标题
xlabel = plt.xlabel('城市',fontsize=14,color='yellow')#设置X轴轴标题
ylabel = plt.ylabel('职位数量',fontsize=14,color='yellow')#设置Y轴轴标题
#设置说明,位置在图的右上角
text1 = ax1.text(25,4500,'城市总数:30(个)',fontsize=12, color='cyan')#设置说明,位置在图的右上角
text2 = ax1.text(25,4000,'职位总数:18326(条)',fontsize=12, color='cyan')
text3 = ax1.text(25,3500,'有效职位:18211(条)',fontsize=12, color='red')
#添加每一个城市的坐标值
for i in range(len(list_1)):
ax1.text(i-0.3,list_1[i],str(list_1[i]),color='yellow')
#可以用plt.grid(True)添加栅格线
#可以用下面语句添加注释箭头。指向上海,xy为坐标值、xytext为注释坐标值,facecolor为箭头颜色。
#arrow = plt.annotate('职位数:3107', xy=(1,3107), xytext=(3, 4000),color='blue',arrowprops=dict(facecolor='blue', shrink=0.05))
ax2 = fig1.add_subplot(2,1,2)#设置子图2,是位于子图1下面的饼状图
#为了方便,显示前8个城市的城市名称和比例、其余的不显示,用空字符列表替代,为此需要构造列表label_list和一个空字符列表['']*23。
x = df_工作城市.value_counts().values#x是数值列表,pie图的比例根据数值占整体的比例而划分
label_list = []#label_list是构造的列表,装的是前8个城市的名称+职位占比。
for i in range(8):
t = df_工作城市.value_counts().values[i]/df_工作城市.value_counts().sum()*100
city = df_工作城市.value_counts().index[i]
percent = str('%.1f%%'%t)
label_list.append(city+percent)
#labels参数原本是与数值对应的标签列表,此处30个城市过多,所以只取了前8个城市显示。
#explode即饼图中分裂的效果explode=(0.1,1,1,。。)表示第一块图片显示为分裂效果
labels = label_list + ['']*22
explode = tuple([0.1]+[0]*29)
plt.pie(x,explode=explode,labels=labels,textprops={'color':'yellow'})
#可加参数autopct='%1.1f%%'来显示饼图中每一块的比例,但是此处30个城市,如果全显示的话会非常拥挤不美观,所以只能手动通过labels参数来构造。
#若要显示标准圆形,可以添加:plt.axis('equal')
&/code&&/pre&&/div&&figure&&img src=&https://pic4.zhimg.com/50/v2-131ba26ddec_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&1266& data-rawheight=&737& class=&origin_image zh-lightbox-thumb& width=&1266& data-original=&https://pic4.zhimg.com/50/v2-131ba26ddec_r.jpg&&&/figure&&p&可以看见,这个曲线下降的弧度还是挺美的,北上深杭广5个城市占据了超过60%以上的职位数。其中北京当之无愧的占据了四分之一的Python工作数量,不愧为帝都。 上海以3107条职位排名第二,可见上海虽然经济超越北京,在互联网环境和工作机遇方面还需努力!深圳作为中国的科技中心,排名第三我是没疑问的,杭州竟然超过广州排名第四!不过也可以想到,阿里巴巴、百草味等等电商产业带动了整个杭州的互联网文化!&br&【北上深杭广】+成都、南京、郑州,这8个城市占据了全国30座城市中,近80%的工作机会!剩下的22个城市合起来只占据了20%,果然,是基本符合28定律的。。。&/p&&h2&2.工作经验-职位数量及分布&/h2&&p&Python虽然是一名比较老的语言,但是在人们的印象中火起来也就最近几年,Python相关的工作对于【工作经验】是怎样要求的呢?让我们来看看!&/p&&div class=&highlight&&&pre&&code class=&language-text&&df.工作经验.value_counts()#统计【工作经验】下各个字段的累计和
&/code&&/pre&&/div&&figure&&img src=&https://pic4.zhimg.com/50/v2-f7cd3ef51e5d6341a60dd_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&358& data-rawheight=&313& class=&content_image& width=&358&&&/figure&&p&可以看见出现了一些很数字少量的字段譬如“5年以上”,“2年以上”,“1-2年”,“1年以上”等,这些标签下职位的数量都在10以内,不太具备统计意义,所以我们作图的时候不想让他们出现,必须筛选掉。 下面我们还是通过同样的步骤来清除掉此类数据。&/p&&div class=&highlight&&&pre&&code class=&language-text&&= df['工作经验'].replace(['found no element','3年以上','1年以上','5年以上','2年以上','1-2年'],np.nan)
df_工作经验.value_counts()
df_工作经验.value_counts().sum()
&/code&&/pre&&/div&&figure&&img src=&https://pic3.zhimg.com/50/v2-da9ddb13ff92e87081aed5_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&814& data-rawheight=&353& class=&origin_image zh-lightbox-thumb& width=&814& data-original=&https://pic3.zhimg.com/50/v2-da9ddb13ff92e87081aed5_r.jpg&&&/figure&&p&现在,可以进行下一步可视化了,还是做2张图:直方图和饼图。通过这两张图可以直观地看到这么多职位中对不同工作经验的要求占比,好做到心里有数!&/p&&div class=&highlight&&&pre&&code class=&language-text&&fig2 = plt.figure(2,facecolor = 'black')
ax2_1 = fig2.add_subplot(2,1,1,facecolor='#4f4f4f',alpha=0.3)
plt.tick_params(colors='white')
df_工作经验.value_counts().plot(kind = 'bar',rot = 0,color='#7fc8ff')
title = plt.title('工作经验——职位数分布图',fontsize = 18,color = 'yellow')
xlabel = plt.xlabel('工作经验',fontsize = 14,color = 'yellow')
ylabel = plt.ylabel('职位数量',fontsize = 14,color = 'yellow')
plt.grid(True)
text1_ = ax2_1.text(5,5600,'城市总数:30(个)',fontsize=12, color='yellow')
text2 = ax2_1.text(5,4850,'职位总数:18326(条)',fontsize=12, color='yellow')
text3 = ax2_1.text(5,4100,'有效职位:18215(条)',fontsize=12, color='cyan')
&/code&&/pre&&/div&&p&&br&&/p&&div class=&highlight&&&pre&&code class=&language-text&&#设置子图2,是位于子图1下面的饼状图
ax2_2 = fig2.add_subplot(2,1,2)
#x是数值列表,pie图的比例根据数值占整体的比例而划分
x2 = df_工作经验.value_counts().values
labels = list(df_工作经验.value_counts().index[:5])+ ['']*2
explode = tuple([0.1,0.1,0.1,0.1,0.1,0.1,0.1])
plt.pie(x2,explode=explode,labels=labels,autopct='%1.1f%%',textprops={'color':'yellow'})
plt.axis('equal')#显示为等比例圆形
#设置图例,方位为右下角
legend = ax2_2.legend(loc='lower right',shadow=True,fontsize=12,edgecolor='cyan')
&/code&&/pre&&/div&&figure&&img src=&https://pic3.zhimg.com/50/v2-2c9de5eb33d9a655cb85c_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&1268& data-rawheight=&740& class=&origin_image zh-lightbox-thumb& width=&1268& data-original=&https://pic3.zhimg.com/50/v2-2c9de5eb33d9a655cb85c_r.jpg&&&/figure&&p&总共得到18215条职位。从直方图里可以明显看出工作机会集中在'不限'、'1-3年'、'3-5年', 其中工作经验要求3年以下的(【无经验】+【不限】+【1年以下】+【1-3年】)合计11501条职位,占比超过63%,看来即使是初入门者,大家的机会也还是有不少的! (PS:最后,在df表中添加一列'df_工作经验',以后筛选时就可以直接用了,df['df_工作经验']=df_工作经验)&/p&&h2&3.工作经验-平均月薪&/h2&&p&这个嘛,大家闭着眼都能想到!肯定是工作经验越久的拿钱越多了!再猜猜?无经验的和5-10年经验的收入差距有多大?这个,嘿嘿就不好猜了,让我们来看看吧!&/p&&p&1.第一步,要想统计工作经验和平均月薪的关系,那么我们先看看df中对应的列df.工作经验和df.average。之前我们构造了一列df_工作经验,把df.工作经验中几个样本容量小于10的值和‘found no element’全筛选掉了,故df_工作经验还能继续使用。现在,让我们看看df.average的信息。&/p&&div class=&highlight&&&pre&&code class=&language-text&&df.average.value_counts()
&/code&&/pre&&/div&&p&可以看到,其中有1265个值是‘面议’,有95个值是‘found no element’,这些值需要替换成空值,不然会影响下一步工资的计算。&/p&&div class=&highlight&&&pre&&code class=&language-text&&df_平均月薪 = df['average'].replace(['面议','found no element'],np.nan)
&/code&&/pre&&/div&&p&2.好了,第一步的简单数据清洗完成了,我们可以思考下一步了,现在我们想要得到的是不同工作经验字段下的平均月薪&/p&&p&A. 首先我需要把df_工作经验和df_平均月薪这两列元素放在一起,构造一个DataFrame用于存放df_工作经验和df_平均月薪这两列元素,且方便进一步的groupby操作。&br&B. 其次我需要把df_平均月薪列根据df_工作经验进行分组(用groupby),分组后我可以求得df_工作经验下各个字段的月薪的计数、最大值最小值、累加和、平均值等一系列数据。&br&C. 当然此处我只需要平均值。对分组后的grouped用mean()方法,就可以轻松统计分组内各项的平均值了。&/p&&div class=&highlight&&&pre&&code class=&language-text&&df3=pd.DataFrame(data={'工作经验':df['df_工作经验'],'平均月薪':df_平均月薪})
df3.info()
grouped3 = df3['平均月薪'].groupby(df3['工作经验'])
grouped3.mean()
&/code&&/pre&&/div&&figure&&img src=&https://pic2.zhimg.com/50/v2-b1fb6e906acb1b6c0105aea3cbfc01fa_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&566& data-rawheight=&349& class=&origin_image zh-lightbox-thumb& width=&566& data-original=&https://pic2.zhimg.com/50/v2-b1fb6e906acb1b6c0105aea3cbfc01fa_r.jpg&&&/figure&&p&在进行grouped3.mean()时,我们发现报错了:DataError: No numeric types to aggregate,看一下,原来df_平均月薪列里的值都是字符型str,并不是数值型的float,因为前面的步骤没有做好,留下了这个bug,无奈我们需要对值类型做个转换。&/p&&div class=&highlight&&&pre&&code class=&language-text&&#构造一个listi存放转化后float型的‘平均月薪’
pattern = re.compile('([0-9]+)')
listi = []
for i in range(len(df.average)):
item = df.average.iloc[i].strip()
result = re.findall(pattern,item)
if result:
listi.append(float(result[0]))
elif (item.strip()=='found no element' or item.strip()=='面议'):
listi.append(np.nan)
print(item)
except Exception as e:
print(item,type(item),repr(e))
#将df3.平均月薪列替换掉,同时给df新增一列'df_平均月薪'做备用。
df3['平均月薪'] = listi
df['df_平均月薪'] = df3['平均月薪']
#看看更新后的数据是否正确
df3['平均月薪'].value_counts()#统计每个月薪字段的个数
df3['平均月薪'][:10]#查看前10个值
type(df3['平均月薪'][1])#看看现在月薪的类型是不是浮点型
df3['平均月薪'].value_counts().sum()#看看月薪样本总数
df3['平均月薪'].mean()#看看这16966个月薪样本的平均值是多少?
&/code&&/pre&&/div&&figure&&img src=&https://pic2.zhimg.com/50/v2-46e8184cff84166bd14c_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&457& data-rawheight=&438& class=&origin_image zh-lightbox-thumb& width=&457& data-original=&https://pic2.zhimg.com/50/v2-46e8184cff84166bd14c_r.jpg&&&/figure&&p&可以看到,替换后的df3['平均月薪']值从str变为了可以计算的float,月薪样本总数16966个,样本的平均月薪14197元。好,现在终于OK了,让我们再回到之前的步骤:&/p&&div class=&highlight&&&pre&&code class=&language-text&&grouped3 = df3['平均月薪'].groupby(df3['工作经验'])
grouped3.mean()
&/code&&/pre&&/div&&figure&&img src=&https://pic4.zhimg.com/50/v2-9dbc4da056a42ba96d731_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&583& data-rawheight=&252& class=&origin_image zh-lightbox-thumb& width=&583& data-original=&https://pic4.zhimg.com/50/v2-9dbc4da056a42ba96d731_r.jpg&&&/figure&&p&好了,完美,格式对了,数据有了,现在可以来画图了!但是再看看,还不是那么完美,数据大小排列很乱,而且小数点那么多。。。好吧,让我们再简单处理下&/p&&div class=&highlight&&&pre&&code class=&language-text&&#新增一个平均值,即所有非空df3['平均月薪']的平均值
s3 = pd.Series(data = {'平均值':df3['平均月薪'].mean()})
result3 = grouped3.mean().append(s3)
#sort_values()方法可以对值进行排序,默认按照升序,round(1)表示小数点后保留1位小数。
result3.sort_values(ascending=False).round(1)
&/code&&/pre&&/div&&figure&&img src=&https://pic2.zhimg.com/50/v2-b11bebd440a_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&610& data-rawheight=&306& class=&origin_image zh-lightbox-thumb& width=&610& data-original=&https://pic2.zhimg.com/50/v2-b11bebd440a_r.jpg&&&/figure&&p&3.数据可视化&/p&&p&这次我们画一个躺倒的柱状图(barh),用ggplot的风格来画。&/p&&div class=&highlight&&&pre&&code class=&language-text&&matplotlib.style.use('ggplot')
fig3 = plt.figure(3,facecolor = 'black')
ax3 = fig3.add_subplot(1,1,1,facecolor='#4f4f4f',alpha=0.3)
result3.sort_values(ascending=False).round(1).plot(kind='barh',rot=0)
#设置标题、x轴、y轴的标签文本
title = plt.title('工作经验——平均月薪分布图',fontsize = 18,color = 'yellow')
xlabel= plt.xlabel('平均月薪',fontsize = 14,color = 'yellow')
ylabel = plt.ylabel('工作经验',fontsize = 14,color = 'yellow')
#添加值标签
list3 = result3.sort_values(ascending=False).values
for i in range(len(list3)):
ax3.text(list3[i],i,str(int(list3[i])),color='yellow')
#设置标识箭头
arrow = plt.annotate('Python平均月薪:14197元/月', xy=(), xytext=(),color='yellow',fontsize=16,arrowprops=dict(facecolor='cyan', shrink=0.05))
#设置图例注释(16966来源:df2['平均月薪'].value_counts().sum())
text= ax3.text(,'月薪样本数:16966(个)',fontsize=16, color='cyan')
#设置轴刻度文字颜色为白色
plt.tick_params(colors='white')
&/code&&/pre&&/div&&figure&&img src=&https://pic4.zhimg.com/50/v2-76e10a13ebc5d3da79940_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&1311& data-rawheight=&797& class=&origin_image zh-lightbox-thumb& width=&1311& data-original=&https://pic4.zhimg.com/50/v2-76e10a13ebc5d3da79940_r.jpg&&&/figure&&p&通过图表,我们可以直观地看到,Python关键词下的职位月薪是随着工作经验增长而递增的(这不是说了一句废话么?!囧) 其中【无经验】的平均月薪最低,只有5842,相比之下【10年以上】经验的,平均月薪达到了恐怖的34890,约达到了【无经验】月薪的6倍之多!!! 【1年以下】的平均月薪7579,还勉强凑合,【1-3年】的已经破万了,达到了近12000元/月的水准。最后让我们看看平均值吧,由于‘被平均’的缘故,16966条月薪样本的均值是14197元,有没有让你满意呢?&/p&&h2&4.工作城市-平均月薪&/h2&&p&对了,刚才说到北上广深占据了全国大部分的工作机会,那么北上广深的平均月薪如何呢?会不会也碾压小城市?让我们来看看! 和之前的套路一样,我们还是要构造一个DataFrame,包含两列,一列是【平均月薪】,一列是【工作城市】,然后对df4进行groupby操作,还是很简单的!不过,经过上次的教训,平均月薪一定要是数值型的,str型的计算不了。&/p&&div class=&highlight&&&pre&&code class=&language-text&&#此处df['df_工作城市']是之前经过筛选后的30个城市数据
df4=pd.DataFrame(data={'工作城市':df['df_工作城市'],'平均月薪':df['df_平均月薪']})
df4.info()
grouped4 = df4['平均月薪'].groupby(df4['工作城市'])
grouped4.mean()#查看对30个城市分组后,各个城市月薪的平均值
grouped4.count().sum()#查看对30个城市分组后筛选出的平均月薪样本数
#新增一个平均值,即所有非空df2['平均月薪']的平均值
s4 = pd.Series(data = {'平均值':df['df_平均月薪'].mean()})
result4 = grouped4.mean().append(s4)
#sort_values()方法可以对值进行排序,默认按照升序,round(1)表示小数点后保留1位小数。
result4.sort_values(ascending=False).round(1)
&/code&&/pre&&/div&&figure&&img src=&https://pic3.zhimg.com/50/v2-3b408c0a6be3e22aeb71a_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&551& data-rawheight=&698& class=&origin_image zh-lightbox-thumb& width=&551& data-original=&https://pic3.zhimg.com/50/v2-3b408c0a6be3e22aeb71a_r.jpg&&&/figure&&figure&&img src=&https://pic1.zhimg.com/50/v2-bdadef5d979c4_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&619& data-rawheight=&706& class=&origin_image zh-lightbox-thumb& width=&619& data-original=&https://pic1.zhimg.com/50/v2-bdadef5d979c4_r.jpg&&&/figure&&p&数据构造好了,进行下一步,可视化。&/p&&div class=&highlight&&&pre&&code class=&language-text&&#可以通过style.available查看可用的绘图风格,总有一款适合你
matplotlib.style.use('dark_background')
fig4 = plt.figure(4)
ax4 = fig4.add_subplot(1,1,1)#可选facecolor='#4f4f4f',alpha=0.3,设置子图,背景色灰色,透明度0.3
result4.sort_values(ascending=False).round(1).plot(kind='bar',rot=30)#可选color='#ef9d9a'
#设置图标题,x和y轴标题
title = plt.title(u'城市——平均月薪分布图',fontsize=18,color='yellow')#设置标题
xlabel = plt.xlabel(u'城市',fontsize=14,color='yellow')#设置X轴轴标题
ylabel = plt.ylabel(u'平均月薪',fontsize=14,color='yellow')#设置Y轴轴标题
#设置说明,位置在图的右上角
text1 = ax4.text(25,16250,u'城市总数:30(个)',fontsize=12, color='#FF00FF')#设置说明,位置在图的右上角
text2 = ax4.text(25,15100,u'月薪样本数:16946(条)',fontsize=12, color='#FF00FF')
#添加每一个城市的坐标值
list_4 = result4.sort_values(ascending=False).values
for i in range(len(list_4)):
ax4.text(i-0.5,list_4[i],int(list_4[i]),color='yellow')
#设置箭头注释
arrow = plt.annotate(u'全国月薪平均值:14197元/月', xy=(4.5,14197), xytext=(7,15000),color='#9B30FF',fontsize=14,arrowprops=dict(facecolor='#FF00FF', shrink=0.05))
#设置轴刻度文字颜色为粉色
plt.tick_params(colors='pink')
&/code&&/pre&&/div&&figure&&img src=&https://pic3.zhimg.com/50/v2-5b97b12128fea0cdb97f_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&1310& data-rawheight=&820& class=&origin_image zh-lightbox-thumb& width=&1310& data-original=&https://pic3.zhimg.com/50/v2-5b97b12128fea0cdb97f_r.jpg&&&/figure&&p&可以看见,Python这个关键词下,全国16946条样本的月薪平均值为14197元/月,平均月薪排名前5的城市分别是:北京、上海、深圳、杭州、广州。哎,记得之前城市—职位数分布图么?全国30个城市中,职位数排名前5 的也是这5座城市!看来北上广深杭不仅集中了全国大部分的职位数量、连平均工资也是领跑全国的!不禁让人觉得越大越强!但是在超级大城市奋斗,买房总是遥遥无期,房子在中国人的概念里,有着特殊的情节,意味着家,老小妻儿生活的地方,给人一种安全感!我们可以看到还有不少城市的平均月薪也破万了,在这些相对小点的城市中挑一个,工作安家,买房还是有希望的,哈哈!譬如南京、武汉、苏州、大连、厦门都挺好的!&/p&&h2&5.学历-职位数量&/h2&&p&直觉来看Python这类工作职位,应该是本科及以上经验要求居多吧?那么工作经验【不限】和【大专】的机会占比多少呢?让我们来看看! 首先,还是用df['最低学历'].value_counts()来看一下有哪些字段,以及各个字段的统计值。&/p&&div class=&highlight&&&pre&&code class=&language-text&&df['最低学历'].value_counts()
df_最低学历=df['最低学历'].replace(['中技','其他','高中','found no element'],np.nan)
df_最低学历.value_counts()
df_最低学历.value_counts().sum()
df['df_最低学历'] = df_最低学历 #留作备用
&/code&&/pre&&/div&&figure&&img src=&https://pic3.zhimg.com/50/v2-5a74bff15bad_b.jpg& data-caption=&& data-size=&normal& data-rawwidth=&737& data-rawheight=&571& class=&origin_image zh-lightbox-thumb& width=&737& data-original=&https://pic3.zhimg.com/50/v2-5a74bff15bad_r.jpg&&&/figure&&p&可以看到对于学历要求,最多的集中在大专、本科、硕士、不限还有较少量的博士和中专学历,至于

我要回帖

更多关于 文件在另一个程序中打开无法删除 的文章

 

随机推荐