a = {'age': 12, 'name': 'b'}
print(a.get('bb', 'N/A'))
N/A
print(sum(range(1, 101)))
5050
import sys
print(dir(sys))
['__breakpointhook__', '__displayhook__', '__doc__',
'__excepthook__', '__interactivehook__', '__loader__',
'__name__', '__package__', '__spec__', '__stderr__',
'__stdin__', '__stdout__', '__unraisablehook__',
'_base_executable', '_clear_type_cache', '_current_frames',
'_debugmallocstats', '_enablelegacywindowsfsencoding',
'_framework', '_getframe', '_git', '_home', '_xoptions',
'addaudithook', 'api_version', 'argv', 'audit', 'base_exec_prefix',
'base_prefix', 'breakpointhook', 'builtin_module_names',
'byteorder', 'call_tracing', 'callstats', 'copyright',
'displayhook', 'dllhandle', 'dont_write_bytecode',
'exc_info', 'excepthook', 'exec_prefix', 'executable',
'exit', 'flags', 'float_info', 'float_repr_style',
'get_asyncgen_hooks', 'get_coroutine_origin_tracking_depth',
'getallocatedblocks', 'getcheckinterval', 'getdefaultencoding',
'getfilesystemencodeerrors', 'getfilesystemencoding', 'getprofile',
'getrecursionlimit', 'getrefcount', 'getsizeof', 'getswitchinterval',
'gettrace', 'getwindowsversion', 'hash_info', 'hexversion',
'implementation', 'int_info', 'intern', 'is_finalizing',
'maxsize', 'maxunicode', 'meta_path', 'modules', 'path',
'path_hooks', 'path_importer_cache', 'platform', 'prefix',
'pycache_prefix', 'set_asyncgen_hooks',
'set_coroutine_origin_tracking_depth', 'setcheckinterval',
'setprofile', 'setrecursionlimit', 'setswitchinterval',
'settrace', 'stderr', 'stdin', 'stdout', 'thread_info',
'unraisablehook', 'version', 'version_info', 'warnoptions', 'winver']
import sys
print(range.__doc__)
range(stop) -> range object
range(start, stop[, step]) -> range object
Return an object that produces a sequence of integers from start (inclusive)
to stop (exclusive) by step. range(i, j) produces i, i+1, i+2, ..., j-1.
start defaults to 0, and stop is omitted! range(4) produces 0, 1, 2, 3.
These are exactly the valid indices for a list of 4 elements.
When step is given, it specifies the increment (or decrement).
webbrowser库
import webbrowser
webbrowser.open('http://www,baidu.com')
if name == '小明':
print('听我的')
elif name == '小花':
pass
def square(x):
"""返回平方值"""
return x*x
print(square.__doc__)
返回平方值
class Person:
def __name(self):
print('私有方法')
class A:
pass
class B(A):
pass
print(issubclass(B, A))
True
import random
print(random.choice([1, 'two', 3, 4]))
1
人生漫漫其修远兮,网安无止境。
一同前行,加油!