question No. 0004: any plain text file in English, counting the number of occurrences of the word.
---------------------------------------------------------------------------
#Source:https://github.com/show-me-the-code/show-me-the-code#Author:renzongxian#date:2014-12-07#Python 3.4"""question No. 0004: Any plain text file in English, counting the number of occurrences of the word. """ImportSYSdefWord_count (file_path): File_object= Open (File_path,'R') Word_num=0 forLineinchfile_object:line_list=line.split () word_num+=Len (line_list) file_object.close ()returnWord_numif __name__=="__main__": ifLen (SYS.ARGV) <= 1: Print("need at least 1 parameter. Try to execute ' python 0004.py $image _path '") Else: forInFileinchSys.argv[1:]: Try: Print("The total number of words is", Word_count (infile))exceptIOError:Print("Can ' t open file!") Pass
Test
Why is my contributions not showing to my profile? Your Profile Contributions graph was a record of contributions you ' ve made to GitHub repositories. Contributions is only counted if they meet certain criteria. In some cases, we are need to rebuild your graph in order for contributions to appear. Contributions that is countedissues and pull requestsissues and pull requests would appear on your contributions graph if They meet both of these conditions:they were opened within the past year. They were opened in a standalone repository, not a fork. Commitscommits would appear on your contributions graph if they meet all of the following conditions:the commits were made Within the past year. The email address used for the commits are associated with your GitHub account. The commits were made in a standalone repository and not a fork. The commits were made:in the repository ' s default branch (usually master) in the Gh-pages branch (for repositories with Pro ject Pages sites) In addition, at least one of The following must be True:you is a collaborator on the repository or is a member of the organization that owns the rep Ository. You have forked the repository. You are opened a pull request or issue in the repository. You have starred the repository.
A Python applet--0004 every day