最近在github上發(fā)現(xiàn)了一個(gè)有意思的項(xiàng)目,很適合初學(xué)者學(xué)習(xí)python代碼。
學(xué)習(xí)一門(mén)語(yǔ)言剛開(kāi)始的時(shí)候是很枯燥的,各種概念語(yǔ)法以及無(wú)聊的打印都會(huì)讓人失去更進(jìn)一步學(xué)習(xí)的動(dòng)力。
很多同學(xué)在學(xué)習(xí)了一段時(shí)間之后甚至?xí)岩蓪W(xué)習(xí)語(yǔ)言的用處,因?yàn)榭偸菍?xiě)不出東西,只會(huì)寫(xiě)一些簡(jiǎn)單的打印代碼。
這個(gè)叫做geekcomputers/Python的項(xiàng)目很好的回答了一個(gè)問(wèn)題,就是學(xué)習(xí)python可以做什么。
仔細(xì)觀察里面的例子,我們可以發(fā)現(xiàn)寫(xiě)一些簡(jiǎn)單的python代碼就可以做很多有意思的事情,比如
- 批量修改文件的后綴名
- 顯示文件的一些信息
- 測(cè)試某個(gè)文件夾是否存在,不存在就自動(dòng)創(chuàng)建
- 搜索所有目錄下的log文件,并自動(dòng)壓縮歸檔
- 把所有創(chuàng)建時(shí)間超過(guò)240天的文件移動(dòng)到某個(gè)文件夾
- 自動(dòng)發(fā)twitter
- 下載最新的漫畫(huà)
- 下載視頻網(wǎng)站的視頻
- ......
這些例子的代碼都很簡(jiǎn)單,推薦大家這樣學(xué)習(xí)
- 首先照著這些代碼敲一遍
- 讓代碼可以正確運(yùn)行
- 為每一行代碼寫(xiě)上注釋
- 只保留注釋,去掉具體代碼,看看自己能不能寫(xiě)出來(lái)
相信經(jīng)過(guò)一段時(shí)間的努力,你應(yīng)該可以熟練使用python去實(shí)現(xiàn)一些簡(jiǎn)單有趣的功能了。
最后附上例子的鏈接。
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
testdirexists, 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
*.logfiles 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.txtand 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.