#!/usr/bin/env python def wordCount(s): chars = len(s) words = len(s.split()) lines = s.count(‘\n‘) print lines, words, chars s = open(‘/etc/passwd‘).read() wordCount(s)
时间: 2024-10-11 20:51:39
#!/usr/bin/env python def wordCount(s): chars = len(s) words = len(s.split()) lines = s.count(‘\n‘) print lines, words, chars s = open(‘/etc/passwd‘).read() wordCount(s)