Chapter 9 Answers to exercises in Python core programming (2)

Source: Internet
Author: User

9-9. py Thon document string. Go to the directory where the python standard library is located. Check each. py file to see if there is any
_ Doc _ string. If yes, sort the format properly.ProgramAfter the execution is completed,
Beautiful list. lists which modules have document strings and the content of document strings.

The name of the character string module.

# Filename: test9-9.pyimport OSHAS = [] nhas = [] def doc_string (): OS. chdir ("G: \ Python") CWD = OS. getcwd () # print CWD doclist = OS. listdir (CWD) for D in doclist: Path = OS. path. join (CWD, d) # print path if OS. path. isfile (PATH): h_doc = 0 fp = open (path, 'R') for line in FP: If '\ ''In line: Has. append (PATH) h_doc = 1 break if h_doc = 0: nhas. append (PATH) FP. close () print "Doc has _ Doc __:", has print "\ ndoc hasn' t _ Doc __:", nhas doc_string ()

All functions are not completed, such as output document string

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.