最近在github上发现了一个有意思的项目,很适合初学者学习python代码。

学习一门语言刚开始的时候是很枯燥的,各种概念语法以及无聊的打印都会让人失去更进一步学习的动力。

很多同学在学习了一段时间之后甚至会怀疑学习语言的用处,因为总是写不出东西,只会写一些简单的打印代码。

这个叫做geekcomputers/Python的项目很好的回答了一个问题,就是学习python可以做什么。

仔细观察里面的例子,我们可以发现写一些简单的python代码就可以做很多有意思的事情,比如

  • 批量修改文件的后缀名
  • 显示文件的一些信息
  • 测试某个文件夹是否存在,不存在就自动创建
  • 搜索所有目录下的log文件,并自动压缩归档
  • 把所有创建时间超过240天的文件移动到某个文件夹
  • 自动发twitter
  • 下载最新的漫画
  • 下载视频网站的视频
  • ......

这些例子的代码都很简单,推荐大家这样学习

  • 首先照着这些代码敲一遍
  • 让代码可以正确运行
  • 为每一行代码写上注释
  • 只保留注释,去掉具体代码,看看自己能不能写出来

相信经过一段时间的努力,你应该可以熟练使用python去实现一些简单有趣的功能了。

最后附上例子的链接。

  • batch_file_rename.py - This batch renames a group of files in a given directory, once you pass the current and the new extensions.

  • create_dir_if_not_there.py - Checks to see if a directory exists in the users home directory, if not then create it.

  • Fast Youtube Downloader - Downloads youtube videos quickly with parallel threads using aria2c

  • Google Image Downloader - Query the specific term and retrieve images from the google image database.

  • dir_test.py - Tests to see if the directory testdir exists, if not it will create the directory for you.

  • env_check.py - This script will check to see if all of the environment variables required are set.

  • fileinfo.py - Shows file information for a given file.

  • folder_size.py - Scans the current directory and all subdirectories and displays the size.

  • logs.py - This script will search for all *.log files in the given directory, zip them using the program you specify, and then date stamp them.

  • move_files_over_x_days.py - Moves all files over 240 days old from the source directory to the destination directory.

  • nslookup_check.py - This simple script opens the file server_list.txt and then does an nslookup for each one to check the DNS entry.

  • osinfo.py - Displays some information about the OS on which you are running this script.

  • ping_servers.py - This script, depending on the arguments supplied, will ping the servers associated with that application group.

  • ping_subnet.py - After supplying the first 3 octets this file scans the final range for available addresses.

  • powerdown_startup.py - This file goes through the server list and pings the machine, if it is up it will load the putty session, if it is not it will notify you.

  • puttylogs.py - This file zips up all the logs in the given directory.

  • script_count.py - This file scans the scripts directory and gives a count of the different types of scripts.

  • script_listing.py - This file will list all the files in the given directory, and go through all the subdirectories as well.

  • testlines.py - This simple script opens a file and prints out 100 lines of whatever is the set for the line variable.

  • tweeter.py - This script allows you to tweet text or a picture from the terminal.

  • serial_scanner.py contains a method called ListAvailablePorts which returns a list with the names of the serial ports that are in use in the computer, this method works only on Linux and Windows (can be extended for mac osx). If no port is found, an empty list is returned.

  • get_youtube_view.py - This is very simple python script to get more views for your youtube videos. Useful for repeating songs on youtube.

  • CountMillionCharacter.py And CountMillionCharacter2.0.py - Counts character scripts, or how much characters are present on any text based file.

  • xkcd_downloader.py - Downloads the latest XKCD comic and places them in a new folder called "comics".

  • timymodule.py - A great alternative to Pythons 'timeit' module and easier to use.

  • calculator.py - Uses Python's eval() function to implement a calculator.

  • Google_News.py - Uses BeautifulSoup to provide Latest News Headline along with news link.

  • cricket_live_score - Uses BeautifulSoup to provide live cricket score.

  • youtube.py - Takes a song name as input and fetches the youtube url of the best matching song and plays it.

适合初学者的python实际例子的更多相关文章

  1. 适合初学者的Python爬取链家网教程

    前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: TinaLY PS:如有需要Python学习资料的小伙伴可以加点击下 ...

  2. 为什么Python适合初学者,一般要学习多久

    为什么Python适合初学者?一般Python要学习多久?很多人都觉得,Python是一门很好学的语言,非常适合入门.但更多人都是不清楚具体原因的.那么,我们不如一起来看看Python为何更适合初学者 ...

  3. 学习python最难的就是入门,而这文章刚好适合初学者!

    Python可以应用于众多领域,如:数据分析.组件集成.网络服务.图像处理.数值计算和科学计算等众多领域.目前业内几乎所有大中型互联网企业都在使用Python,如:Youtube.Dropbox.BT ...

  4. [C#] Timer + Graphics To Get Simple Animation (简单的源码例子,适合初学者)

    >_<" 这是一个非常简单的利用C#的窗口工程创立的程序,用来做一个简单的动画,涉及Timer和Graphics,适合初学者,高手略过~

  5. Vue slot-scope的理解(适合初学者)

    百度上已经有很多的关于slot-scope的文章,但我感觉都是那些以前没学好,又回头学的人,他们都使用了.Vue文件,我觉得有点不适合初学者,所以我就写一篇适合初学者的. 先抛例程: <!DOC ...

  6. 推荐10个适合初学者的 HTML5 入门教程

    HTML5 作为下一代网站开发技术,无论你是一个 Web 开发人员或者想探索新的平台的游戏开发者,都值得去研究.借助尖端功能,技术和 API,HTML5 允许你创建响应性.创新性.互动性以及令人惊叹的 ...

  7. 5、WPF实现简单计算器-非常适合初学者练习

    Sample Calculator 这是微软社区WPF的一个示例,在源程序的基础上我进行了一点点修改,非常适合初学者练习,详细代码解释. 源程序的下载地址 http://code.msdn.micro ...

  8. 强烈推荐visual c++ 2012入门经典适合初学者入门

    强烈推荐visual c++ 2012入门经典适合初学者入门 此书循序渐进,用其独特.易于理解的教程风格来介绍各个主题,无论是编程新手,还是经验丰富的编程人员,都很容易理解. 此书的目录基本覆盖了Wi ...

  9. Linux内核开发进阶书籍推荐(不适合初学者)

    Linux内核开发进阶书籍推荐(不适合初学者) 很早之前就想写一篇文章总结一下Linux Kernel开发的相关资料,项目的原因,再加上家里的一些事情,一直没能找到闲暇,今天终于有些时间,希望可以完成 ...

随机推荐

  1. Codeforces 659G Fence Divercity dp

    Fence Divercity 我们设a[ i ] 为第 i 个围栏被切的最靠下的位置, 我们发现a[ i ] 的最大取值有一下信息: 如果从i - 1过来并在 i  结束a[ i ] = min(h ...

  2. Dockerfile中ENTRYPOINT 和 CMD的区别

    一.dockerfile中的 CMD 1.每个dockerfile中只能有一个CMD如果有多个那么只执行最后一个. 2.CMD 相当于启动docker时候后面添加的参数看,举个简单例子: docker ...

  3. 6-15 给任务排序 uva10305

    拓扑排序的水题 有关dfs的很好的题 其中c数组的三个状态十分巧妙 还有各种bool的运用 储存答案的方式!!:ans[--t]=x; 因为dfs是先将所有的步骤全部进行完  最后开始疯狂 存答案   ...

  4. 060 关于Hive的调优(本身,sql,mapreduce)

    1.关于hive的优化 ->大表拆分小表 ->过滤字段 ->按字段分类存放 ->外部表与分区表 ->外部表:删除时只删除元数据信息,不删除数据文件 多人使用多个外部表操作 ...

  5. Hdu-1358Period(KMP算法之next数组的应用)

    题解:对于串pattern来说,如果0~i-1这个位置中循环,那么i%(i-next[i])==0 ,循环次数为 i/(i-next[i]),循环长度为 i-next[i] 例如对于串ababab来说 ...

  6. <<c专家编程>>笔记

    C专家编程摘录 c操作符的优先级 有时一些c操作符有时并不会像你想象的那样工作. 下方表格将说明这个问题: 优先级问题 表达式 期望的情况 实际情况 . 优先级高于* *p.f (*p).f *(p. ...

  7. mysql中的用法 count group by having

    1 语法: group by 字段 having 条件判断; group by的用法我已经在上一篇经验中介绍了 2 还是已员工绩效表为例   3 我们如果就是查询每个部门成绩大于89的员工数,可以这样 ...

  8. sleep() 和 wait() 有什么区别?

     sleep:Thread类中定义的方法,表示线程休眠,会自动唤醒: wait:Object中定义的方法,需要手工调用notify()或者notifyAll()方法. sleep是线程类(Thread ...

  9. bzoj4237: 稻草人 cdq分治 单调栈

    目录 题目链接 题解 代码 题目链接 bzoj4237: 稻草人 题解 暴力统计是n^2的 考虑统计一段区间对另一端的贡献 对于y值cdq分治,降调一维 对于当前两个分治区间统计上面那部分对下面那部分 ...

  10. 常用类及 LeetCode 每日一题

    1 日期时间类 在 Java 语言中,是通过时间戳来表示时间的.所谓的时间戳,在 Java 中就是指当前时间距离历元(1970-01-01 00:00:00)的时间间隔,单位是毫秒,所以 Java 中 ...