Get the python default help document

Source: Internet
Author: User

The help documentation for python is very good, that is, sometimes the Help page is provided several times, and even some help cannot be seen at all (I think there should be other methods to solve it, but I don't want to check it ), this can be done through a very simple Python script.
Here is an example. For example, if I want to get the help document of tkinter, in interactive mode, I can enter:

 
>>> Import tkinter
>>> Help (tkinter)

Press enter to see the spectacular screen flushing effect ...... When you scroll the mouse to see the help document, you will find that you cannot find it.
This is clearly not what I need.
Maybe I should not input this type. I input this type, resulting in excessive output.
But the fact is that I really need all the documents about tkinter. What should I do?

I think it is as follows:

File: getpythonhelp2.py:
Code:

 
#! /Usr/bin/Python
ImportTkinter
Help (tkinter)

Usage:
Python getpythonhelp2.py> 1.txt
Direct output is redirected to a file. It is very convenient to view the disk. Haha ......

In fact, there is a more lazy approach. Here we only provide a demo:

 1   # ! /Usr/bin/Python  
2 '''
3 File: getpythonhelp. py
4 Author: Mike
5 E-mail: Mike_Zhang@live.com
6 '''
7 Import Tkinter
8 Import Sys
9
10 TMP = SYS. stdout
11 Fp = open ( " 1. txt " , " W " )
12 SYS. stdout = fp # Redirect stdout
13 Help (tkinter)
14 SYS. stdout = TMP # Recover stdout
15 FP. Close ()

This is my previous article.Article(Http://www.cnblogs.com/MikeZhang/archive/2012/01/19/ioRedirect.html) mentioned inProgramThe implementation of internal Io redirection is similar in principle.

Okay, that's all. I hope it will help you.

Related Article

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.