Dir, help, str usage for Python

Source: Internet
Author: User

When you provide a module name to Dir (), it returns a list of the names defined in that module. When no arguments are provided for it, it returns a list of the names defined in the current module.
The Dir () function uses an example:

123456 >>> importsys  # 获得属性列表,在这里是sys模块的属性列表>>> dir(sys)[‘__displayhook__‘‘__doc__‘‘__excepthook__‘‘__name__‘‘__package__‘‘__stderr__‘‘__stdin__‘‘__stdout__‘‘_clear_type_cache‘‘_compact_freelists‘,‘_current_frames‘‘_getframe‘‘api_version‘‘argv‘, ...]

If you need to quickly get information about any of the Python functions or statements, you can use the built-in Help feature. This is very useful, especially when using the translation prompt, for example, running ' help print '--this will show the print function--for printing things to the screen.

The Help () function uses an example:

1 23456 >>> help (print) help on built- in  function   print  in  module builtins:  print (...)      print (value, ..., sep= '   ' , end= ' \ n ' file =sys.stdout, flush=false) Code class= "Bash plain" > ...

Dir, help, str usage for Python

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.