`
mrjeye
  • 浏览: 177799 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

常用模块

阅读更多
sys
>>> import sys
>>> dir(sys)
['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__', '__s
tderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_g
etframe', 'api_version', 'argv', 'builtin_module_names', 'byteorder', 'call_trac
ing', 'callstats', 'copyright', 'displayhook', 'dllhandle', 'dont_write_bytecode
', 'exc_clear', 'exc_info', 'exc_type', 'excepthook', 'exec_prefix', 'executable
', 'exit', 'flags', 'float_info', 'getcheckinterval', 'getdefaultencoding', 'get
filesystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeo
f', 'gettrace', 'getwindowsversion', 'hexversion', 'last_traceback', 'last_type'
, 'last_value', 'maxint', 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path
', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', 'py3
kwarning', 'setcheckinterval', 'setprofile', 'setrecursionlimit', 'settrace', 's
tderr', 'stdin', 'stdout', 'subversion', 'version', 'version_info', 'warnoptions
', 'winver']

types:包含所有内置TYPE
>>> import types
>>> dir(types)
['BooleanType', 'BufferType', 'BuiltinFunctionType', 'BuiltinMethodType', 'Class
Type', 'CodeType', 'ComplexType', 'DictProxyType', 'DictType', 'DictionaryType',
'EllipsisType', 'FileType', 'FloatType', 'FrameType', 'FunctionType', 'Generato
rType', 'GetSetDescriptorType', 'InstanceType', 'IntType', 'LambdaType', 'ListTy
pe', 'LongType', 'MemberDescriptorType', 'MethodType', 'ModuleType', 'NoneType',
'NotImplementedType', 'ObjectType', 'SliceType', 'StringType', 'StringTypes', '
TracebackType', 'TupleType', 'TypeType', 'UnboundMethodType', 'UnicodeType', 'XR
angeType', '__builtins__', '__doc__', '__file__', '__name__', '__package__']

decimal:十进制浮点数
>>> import decimal
>>> dir(decimal)
['BasicContext', 'Clamped', 'Context', 'ConversionSyntax', 'Decimal', 'DecimalEx
ception', 'DecimalTuple', 'DefaultContext', 'DivisionByZero', 'DivisionImpossibl
e', 'DivisionUndefined', 'ExtendedContext', 'Inexact', 'InvalidContext', 'Invali
dOperation', 'Overflow', 'ROUND_05UP', 'ROUND_CEILING', 'ROUND_DOWN', 'ROUND_FLO
OR', 'ROUND_HALF_DOWN', 'ROUND_HALF_EVEN', 'ROUND_HALF_UP', 'ROUND_UP', 'Rounded
', 'Subnormal', 'Underflow', '_ContextManager', '_Infinity', '_Log10Memoize', '_
NaN', '_NegativeInfinity', '_NegativeOne', '_One', '_SignedInfinity', '_WorkRep'
, '_Zero', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__pack
age__', '_all_zeros', '_condition_map', '_convert_other', '_copy', '_dec_from_tr
iple', '_dexp', '_div_nearest', '_dlog', '_dlog10', '_dpower', '_exact_half', '_
format_align', '_iexp', '_ilog', '_log10_digits', '_log10_lb', '_namedtuple', '_
nbits', '_normalize', '_numbers', '_parse_format_specifier', '_parse_format_spec
ifier_regex', '_parser', '_rshift_nearest', '_signals', '_sqrt_nearest', 'getcon
text', 'localcontext', 'setcontext']

array:高效数值数组

math/cmath:标准数学运算函数

random:多种伪随机数的实现
>>> s=''
>>> for x in range(1,10) :
...     s+=str(random.randrange(1,100))+' '
...
>>> s
'48 19 83 40 40 3 32 70 43 '
>>> random.randint(0,100)
62
>>> lst = (1,2,5,7,9)
>>> lst
(1, 2, 5, 7, 9)
>>> random.choice(lst)
2
>>> random.choice(lst)
9
operator:数字运算符的函数实现

copy:提供浅拷贝和深拷贝功能
copy.copy(obj) #浅拷贝
copy.deepcopy(obj) #深拷贝
re:Perl正则表达式查找配置

collections:高性能容器数据类型
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics