`
linvar
  • 浏览: 254439 次
  • 性别: Icon_minigender_1
  • 来自: 未定
社区版块
存档分类
最新评论

python notes(1)

阅读更多
1. Argument passing:
   When known to the interpreter, the script name and additional arguments thereafter are passed to the script in the variable sys.argv, which is a list of strings. Its length is at least one; when no script and no arguments are given, sys.argv[0] is an empty string. When the script name is given as '-' (meaning standard input), sys.argv[0] is set to '-'. When -c command is used, sys.argv[0] is set to '-c'. When -m module is used, sys.argv[0] is set to the full name of the located module. Options found after -c command or -m module are not consumed by the Python interpreter’s option processing but left in sys.argv for the command or module to handle.

2. Source Code Encoding
   # -*- coding: utf-8 -*-
   by using UTF-8 (either through the signature or an encoding declaration), characters of most languages in the world can be used simultaneously in string literals and comments. Using non-ASCII characters in identifiers is not supported. To display all these characters properly, your editor must recognize that the file is UTF-8, and it must use a font that supports all the characters in the file.

3.Brief Tour of the Standard Library
  The os module provides dozens of functions for interacting with the operating system:
  The glob module provides a function for making file lists from directory wildcard searches
  Command Line Arguments are stored in the sys module’s argv attribute as a list.
  The sys module also has attributes for stdin, stdout, and stderr. The latter is useful for emitting warnings and error messages to make them visible even when stdout has been redirected:
  The re module provides regular expression tools for advanced string processing.
  The math module gives access to the underlying C library functions for floating point math
  The random module provides tools for making random selections
  There are a number of modules for accessing the internet and processing internet protocols. Two of the simplest are urllib2 for retrieving data from urls and smtplib for sending mail:
  The datetime module supplies classes for manipulating dates and times in both simple and complex ways.
  Common data archiving and compression formats are directly supported by modules including: zlib, gzip, bz2, zipfile and tarfile.
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics