python 模塊 導入機制 模塊搜索 Python包 發佈python模塊或程序

python 模塊

python模塊:以.py結尾的代碼文件。
       頂層文件: 程序執行入口
       模塊文件1
       模塊文件2
       模塊文件3

在這裏插入圖片描述

在python中一切皆對象,所以模塊本身也是對象。由於模塊本身是對象所以模塊自己本身也有屬性,也有方法。那麼在一個模塊的頂層 定義的所有變量成爲了被導入模塊的屬性。
在這裏插入圖片描述
當程序執行時,位於模塊中的頂層語句都會執行, def 語句
def f1():
print()

模塊的執行環境:

在這裏插入圖片描述
[注:]一個模塊不應該有太多函數和類之外的代碼,因爲這部分代碼就屬於頂層代碼,在程序剛開始執行時就會被執行,然後調用的時候又會被執行一遍,會增加程序消耗,減慢執行速率。

導入模塊

在這裏插入圖片描述
在這裏插入圖片描述

import 工作機制

在這裏插入圖片描述
”上圖中模塊只在第一導入時候纔會執行以上圖中3步驟(1.找到模塊文件2.編譯成字節碼3.執行模塊的代碼創建其所定義的對象),後續的導入操作只不過是提取內存中已加載的模塊對象。“

模塊搜索

在這裏插入圖片描述
在這裏插入圖片描述
random. __ dict __ 的結果如下:

{’__ name ': ‘random’, ’ doc __’: ‘Random variable generators.\n\n integers\n --------\n
uniform within range\n\n sequences\n ---------\n pick random element\n
pick random sample\n pick weighted random sample\n generate random permutation
\n\n distributions on the real line:\n ------------------------------\n uniform\n
triangular\n normal (Gaussian)\n lognormal\n negative exponent
ial\n gamma\n beta\n pareto\n Weibull\n\n distributions o
n the circle (angles 0 to 2pi)\n ---------------------------------------------\n circul
ar uniform\n von Mises\n\nGeneral notes on the underlying Mersenne Twister core generator:
\n\n* The period is 2**19937-1.\n* It is one of the most extensively tested generators in existence.
\n* The random() method is implemented in C, executes in a single Python step,\n and is, therefore,
threadsafe.\n\n’, ‘package’: ‘’, ‘loader’: <_frozen_importlib_external.SourceFileLoader obj
ect at 0x0000000002F8FAC8>, ‘spec’: ModuleSpec(name=‘random’, loader=<_frozen_importlib_external
.SourceFileLoader object at 0x0000000002F8FAC8>, origin=‘H:\ANACONDA\lib\random.py’), ‘file’:
‘H:\ANACONDA\lib\random.py’, ‘cached’: ‘H:\ANACONDA\lib\pycache\random.cpython-36.py
c’, ‘builtins’: {‘name’: ‘builtins’, ‘doc’: “Built-in functions, exceptions, and other o
bjects.\n\nNoteworthy: None is the nil' object; Ellipsis represents…’ in slices.”, ‘package
‘: ‘’, ‘loader’: <class ‘_frozen_importlib.BuiltinImporter’>, ‘spec’: ModuleSpec(name=‘built
ins’, loader=<class ‘_frozen_importlib.BuiltinImporter’>), ‘build_class’: , ‘import’: , ‘abs’: , ‘all’:
, ‘any’: , ‘ascii’: , ‘bin’:
, ‘callable’: , ‘chr’: , ’
compile’: , ‘delattr’: , ‘dir’: , ‘divmod’: , ‘eval’: , ‘exec’: , ‘format’: , ‘getattr’: , ‘glob
als’: , ‘hasattr’: , ‘hash’: , ‘hex’: , ‘id’: , ‘input’: , ‘isinstance’: , ‘issubclass’: , ’
iter’: , ‘len’: , ‘locals’: <built-in function locals

, ‘max’: , ‘min’: , ‘next’: ,
‘oct’: , ‘ord’: , ‘pow’: , ‘pr
int’: , ‘repr’: , ‘round’: <built-in function round
, ‘setattr’: , ‘sorted’: , ‘sum’: , ‘vars’: , ‘None’: None, ‘Ellipsis’: Ellipsis, ‘NotImplemented’:
NotImplemented, ‘False’: False, ‘True’: True, ‘bool’: <class ‘bool’>, ‘memoryview’: <class ‘memoryv
iew’>, ‘bytearray’: <class ‘bytearray’>, ‘bytes’: <class ‘bytes’>, ‘classmethod’: <class ‘classmetho
d’>, ‘complex’: <class ‘complex’>, ‘dict’: <class ‘dict’>, ‘enumerate’: <class ‘enumerate’>, 'filter
': <class ‘filter’>, ‘float’: <class ‘float’>, ‘frozenset’: <class ‘frozenset’>, ‘property’: <class
‘property’>, ‘int’: <class ‘int’>, ‘list’: <class ‘list’>, ‘map’: <class ‘map’>, ‘object’: <class ‘o
bject’>, ‘range’: <class ‘range’>, ‘reversed’: <class ‘reversed’>, ‘set’: <class ‘set’>, ‘slice’: <c
lass ‘slice’>, ‘staticmethod’: <class ‘staticmethod’>, ‘str’: <class ‘str’>, ‘super’: <class ‘super’
, ‘tuple’: <class ‘tuple’>, ‘type’: <class ‘type’>, ‘zip’: <class ‘zip’>, ‘debug’: True, ‘BaseE
xception’: <class ‘BaseException’>, ‘Exception’: <class ‘Exception’>, ‘TypeError’: <class 'TypeError
'>, ‘StopAsyncIteration’: <class ‘StopAsyncIteration’>, ‘StopIteration’: <class ‘StopIteration’>, ‘G
eneratorExit’: <class ‘GeneratorExit’>, ‘SystemExit’: <class ‘SystemExit’>, ‘KeyboardInterrupt’: <cl
ass ‘KeyboardInterrupt’>, ‘ImportError’: <class ‘ImportError’>, ‘ModuleNotFoundError’: <class ‘Modul
eNotFoundError’>, ‘OSError’: <class ‘OSError’>, ‘EnvironmentError’: <class ‘OSError’>, ‘IOError’: <c
lass ‘OSError’>, ‘WindowsError’: <class ‘OSError’>, ‘EOFError’: <class ‘EOFError’>, ‘RuntimeError’:
<class ‘RuntimeError’>, ‘RecursionError’: <class ‘RecursionError’>, ‘NotImplementedError’: <class ‘N
otImplementedError’>, ‘NameError’: <class ‘NameError’>, ‘UnboundLocalError’: <class ‘UnboundLocalErr
or’>, ‘AttributeError’: <class ‘AttributeError’>, ‘SyntaxError’: <class ‘SyntaxError’>, ‘Indentation
Error’: <class ‘IndentationError’>, ‘TabError’: <class ‘TabError’>, ‘LookupError’: <class ‘LookupErr
or’>, ‘IndexError’: <class ‘IndexError’>, ‘KeyError’: <class ‘KeyError’>, ‘ValueError’: <class ‘Valu
eError’>, ‘UnicodeError’: <class ‘UnicodeError’>, ‘UnicodeEncodeError’: <class ‘UnicodeEncodeError’>
, ‘UnicodeDecodeError’: <class ‘UnicodeDecodeError’>, ‘UnicodeTranslateError’: <class ‘UnicodeTransl
ateError’>, ‘AssertionError’: <class ‘AssertionError’>, ‘ArithmeticError’: <class ‘ArithmeticError’>
, ‘FloatingPointError’: <class ‘FloatingPointError’>, ‘OverflowError’: <class ‘OverflowError’>, ‘Zer
oDivisionError’: <class ‘ZeroDivisionError’>, ‘SystemError’: <class ‘SystemError’>, ‘ReferenceError’
: <class ‘ReferenceError’>, ‘BufferError’: <class ‘BufferError’>, ‘MemoryError’: <class 'MemoryError
'>, ‘Warning’: <class ‘Warning’>, ‘UserWarning’: <class ‘UserWarning’>, ‘DeprecationWarning’: <class
‘DeprecationWarning’>, ‘PendingDeprecationWarning’: <class ‘PendingDeprecationWarning’>, ‘SyntaxWar
ning’: <class ‘SyntaxWarning’>, ‘RuntimeWarning’: <class ‘RuntimeWarning’>, ‘FutureWarning’: <class
‘FutureWarning’>, ‘ImportWarning’: <class ‘ImportWarning’>, ‘UnicodeWarning’: <class 'UnicodeWarning
'>, ‘BytesWarning’: <class ‘BytesWarning’>, ‘ResourceWarning’: <class ‘ResourceWarning’>, ‘Connectio
nError’: <class ‘ConnectionError’>, ‘BlockingIOError’: <class ‘BlockingIOError’>, ‘BrokenPipeError’:
<class ‘BrokenPipeError’>, ‘ChildProcessError’: <class ‘ChildProcessError’>, ‘ConnectionAbortedErro
r’: <class ‘ConnectionAbortedError’>, ‘ConnectionRefusedError’: <class ‘ConnectionRefusedError’>, ‘C
onnectionResetError’: <class ‘ConnectionResetError’>, ‘FileExistsError’: <class ‘FileExistsError’>,
‘FileNotFoundError’: <class ‘FileNotFoundError’>, ‘IsADirectoryError’: <class ‘IsADirectoryError’>,
‘NotADirectoryError’: <class ‘NotADirectoryError’>, ‘InterruptedError’: <class ‘InterruptedError’>,
‘PermissionError’: <class ‘PermissionError’>, ‘ProcessLookupError’: <class ‘ProcessLookupError’>, ‘T
imeoutError’: <class ‘TimeoutError’>, ‘open’: , ‘quit’: Use quit() or Ctrl-Z
plus Return to exit, ‘exit’: Use exit() or Ctrl-Z plus Return to exit, ‘copyright’: Copyright © 2
001-2017 Python Software Foundation.
All Rights Reserved.

Copyright © 2000 BeOpen.com.
All Rights Reserved.

Copyright © 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.

Copyright © 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved., ‘credits’: Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of
thousands
for supporting Python development. See www.python.org for more information., ‘license’: See htt
ps://www.python.org/psf/license/, ‘help’: Type help() for interactive help, or help(object) for help
about object., ‘_’: None}, ‘_warn’: , ‘_MethodType’: <class ‘method’>, ‘_Bu
iltinMethodType’: <class ‘builtin_function_or_method’>, ‘_log’: , ‘_exp’: , ‘_pi’: 3.141592653589793, ‘_e’: 2.718281828459045, ‘_ceil’: , ‘_sqrt’: , ‘_acos’: , ‘_cos’: , ‘_sin’: , ‘_urandom’: , ‘_Set’: <class
‘collections.abc.Set’>, ‘_Sequence’: <class ‘collections.abc.Sequence’>, ‘_sha512’: , ‘_itertools’: <module ‘itertools’ (built-in)>, ‘_bisect’: <module ‘bisect’ from
‘H:\ANACONDA\lib\bisect.py’>, ‘all’: [‘Random’, ‘seed’, ‘random’, ‘uniform’, ‘randint’, ‘choi
ce’, ‘sample’, ‘randrange’, ‘shuffle’, ‘normalvariate’, ‘lognormvariate’, ‘expovariate’, ‘vonmisesva
riate’, ‘gammavariate’, ‘triangular’, ‘gauss’, ‘betavariate’, ‘paretovariate’, ‘weibullvariate’, ‘ge
tstate’, ‘setstate’, ‘getrandbits’, ‘choices’, ‘SystemRandom’], ‘NV_MAGICCONST’: 1.7155277699214135,
‘TWOPI’: 6.283185307179586, ‘LOG4’: 1.3862943611198906, ‘SG_MAGICCONST’: 2.504077396776274, ‘BPF’:
53, ‘RECIP_BPF’: 1.1102230246251565e-16, ‘_random’: <module ‘_random’ (built-in)>, ‘Random’: <class
‘random.Random’>, ‘SystemRandom’: <class ‘random.SystemRandom’>, ‘_test_generator’: <function test
generator at 0x0000000002FAC6A8>, ‘_test’: <function _test at 0x0000000002FCC950>, ‘_inst’: <random.
Random object at 0x0000000002C207A8>, ‘seed’: <bound method Random.seed of <random.Random object at
0x0000000002C207A8>>, ‘random’: <built-in method random of Random object at 0x0000000002C207A8>, ‘un
iform’: <bound method Random.uniform of <random.Random object at 0x0000000002C207A8>>, ‘triangular’:
<bound method Random.triangular of <random.Random object at 0x0000000002C207A8>>, ‘randint’: <bound
method Random.randint of <random.Random object at 0x0000000002C207A8>>, ‘choice’: <bound method Ran
dom.choice of <random.Random object at 0x0000000002C207A8>>, ‘randrange’: <bound method Random.randr
ange of <random.Random object at 0x0000000002C207A8>>, ‘sample’: <bound method Random.sample of <ran
dom.Random object at 0x0000000002C207A8>>, ‘shuffle’: <bound method Random.shuffle of <random.Random
object at 0x0000000002C207A8>>, ‘choices’: <bound method Random.choices of <random.Random object at
0x0000000002C207A8>>, ‘normalvariate’: <bound method Random.normalvariate of <random.Random object
at 0x0000000002C207A8>>, ‘lognormvariate’: <bound method Random.lognormvariate of <random.Random obj
ect at 0x0000000002C207A8>>, ‘expovariate’: <bound method Random.expovariate of <random.Random objec
t at 0x0000000002C207A8>>, ‘vonmisesvariate’: <bound method Random.vonmisesvariate of <random.Random
object at 0x0000000002C207A8>>, ‘gammavariate’: <bound method Random.gammavariate of <random.Random
object at 0x0000000002C207A8>>, ‘gauss’: <bound method Random.gauss of <random.Random object at 0x0
000000002C207A8>>, ‘betavariate’: <bound method Random.betavariate of <random.Random object at 0x000
0000002C207A8>>, ‘paretovariate’: <bound method Random.paretovariate of <random.Random object at 0x0
000000002C207A8>>, ‘weibullvariate’: <bound method Random.weibullvariate of <random.Random object at
0x0000000002C207A8>>, ‘getstate’: <bound method Random.getstate of <random.Random object at 0x00000
00002C207A8>>, ‘setstate’: <bound method Random.setstate of <random.Random object at 0x0000000002C20
7A8>>, ‘getrandbits’: <built-in method getrandbits of Random object at 0x0000000002C207A8>}

查詢python的所有模塊

help(“modules”)

Please wait a moment while I gather a list of all available modules…

H:\ANACONDA\lib\site-packages\IPython\kernel_init_.py:13: ShimWarning: The IPython.kernel packa
ge has been deprecated since IPython 4.0.You should import from ipykernel or jupyter_client instead.

“You should import from ipykernel or jupyter_client instead.”, ShimWarning)
Unreleased!
H:\ANACONDA\lib\site-packages\gensim\utils.py:1209: UserWarning: detected Windows; aliasing chunkize
to chunkize_serial
warnings.warn(“detected Windows; aliasing chunkize to chunkize_serial”)
Using TensorFlow backend.
H:\ANACONDA\lib\site-packages\nltk\twitter_init_.py:20: UserWarning: The twython library has not
been installed. Some functionality from the twitter package will not be available.
warnings.warn("The twython library has not been installed. "
H:\ANACONDA\lib\site-packages\passlib\crypto\scrypt_init_.py:127: PasslibSecurityWarning: Using b
uiltin scrypt backend, which is 100x slower than is required for adequate security. Installing scryp
t support (via ‘pip install scrypt’) is strongly recommended
“is strongly recommended” % slowdown, exc.PasslibSecurityWarning)
#Generating comtypes.gen._944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0
#Generating comtypes.gen.00020430_0000_0000_C000_000000000046_0_2_0
#Generating comtypes.gen.stdole
#Generating comtypes.gen.UIAutomationClient
H:\ANACONDA\lib\pkgutil.py:92: ScrapyDeprecationWarning: Module scrapy.contrib.exporter is depreca
ted, use scrapy.exporters instead
import(info.name)
H:\ANACONDA\lib\pkgutil.py:92: ScrapyDeprecationWarning: Module scrapy.contrib.linkextractors is d
eprecated, use scrapy.linkextractors instead
import(info.name)
H:\ANACONDA\lib\pkgutil.py:92: ScrapyDeprecationWarning: Module scrapy.contrib.loader is deprecate
d, use scrapy.loader instead
import(info.name)
H:\ANACONDA\lib\pkgutil.py:92: ScrapyDeprecationWarning: Module scrapy.contrib.pipeline is depreca
ted, use scrapy.pipelines instead
import(info.name)
H:\ANACONDA\lib\pkgutil.py:92: ScrapyDeprecationWarning: Module scrapy.contrib.spiders is deprecat
ed, use scrapy.spiders instead
import(info.name)
H:\ANACONDA\lib\site-packages\sklearn\ensemble\weight_boosting.py:29: DeprecationWarning: numpy.core
.umath_tests is an internal NumPy module and should not be imported. It will be removed in a future
NumPy release.
from numpy.core.umath_tests import inner1d
H:\ANACONDA\lib\site-packages\sphinx\websupport_init
.py:25: RemovedInSphinx20Warning: sphinx.web
support module is now provided as sphinxcontrib-websupport. sphinx.websupport will be removed at Sph
inx-2.0. Please use the package instead.
RemovedInSphinx20Warning)
H:\ANACONDA\lib\site-packages\qtawesome\iconic_font.py:268: UserWarning: You need to have a running
QApplication to use QtAwesome!
warnings.warn("You need to have a running "

You can find the C code in this temporary file: C:\Users\Public\Documents\Wondershare\CreatorTemp\th
eano_compilation_error_k4ym28z8
In file included from H:\ANACONDA\include/Python.h:116,
from H:\ANACONDA\lib\site-packages\zmq\backend\cffi_pycache__cffi_ext.c:2:
H:\ANACONDA\include/pylifecycle.h:63:1: warning: function declaration isn’t a prototype [-Wstrict-pr
ototypes]
int Py_CheckPython3();
^~~
H:\ANACONDA\lib\site-packages\zmq\backend\cffi_pycache
_cffi_ext.c:213:10: fatal error: sys/un.h
: No such file or directory
#include <sys/un.h>
^~~~~~~~~~
compilation terminated.

Crypto       comtypes        mitie        sklearn_crfsuite
Cython       concurrent        mitmproxy        slackclient
IPython        conda        mkl         smart_open
OleFileIO_PL        conda_build         mmap         smtpd
OpenSSL        conda_env        mmapfile         smtplib
PIL         conda_verify         mmsystem         sndhdr
PyInquirer        config        modulefinder         snowballstemmer
PyQt4        configargparse         mpmath         socket
PyQt5         configparser        msgpack        socketio
future        constantly        msilib        socketserver
_ast        contextlib         msvcrt        socks
_asyncio         contextlib2         multipledispatch        sockshandler
_bisect        copy         multiprocessing         sortedcollections
_blake2        copyreg        murmurhash        sortedcontainers
_bootlocale        corsheaders        navigator_updater        sphinx
_bz2         crypt         nbconvert         sphinxcontrib
_cffi_backend         cryptography         nbformat         spyder
_codecs         cssselect         neo4j         spyder_breakpoints
_codecs_cn         csv         neokit         spyder_io_dcm
_codecs_hk         ctypes         neotime         spyder_io_hdf5
_codecs_iso2022        curl         netbios         spyder_profiler
_codecs_jp         curses        netrc        spyder_pylint
_codecs_kr         cv         networkx         sqlalchemy
_codecs_tw         cv2         nltk         sqlite3
_collections         cwp         nntplib         sre_compile
_collections_abc         cycler         nose         sre_constants
_compat_pickle         cymem         notebook         sre_parse
_compression        cython         nt         ssl
_csv         cythonmagic         ntpath         sspi
_ctypes         cytoolz         ntsecuritycon         sspicon
_ctypes_test         dask         nturl2path         stat
_datetime         datetime         numbers         statistics
_decimal         dateutil         numpy         storemagic
_dummy_thread         dbi         numpydoc         string
_elementtree         dbm         odbc         stringprep
_functools         dde         olefile         struct
_hashlib         decimal         opcode         subprocess
_heapq         decorator         openpyxl         sunau
_imp         difflib         operator         surprise
_io         dill         optparse         symbol
_json         dis         os         sympy
_locale         distance         packaging         sympyprinting
_lsprof         distlib         pandas         symtable
_lzma         distributed         pandocfilters         sys
_markupbase         distutils         parsel         sysconfig
_md5         django         parser         tabnanny
_msi         docopt         parso         tabulate
_multibytecodec         doctest         partd         tarfile
_multiprocessing         docutils         passlib         tblib
_nsis         dukpy         past         telegram
_opcode         dummy_threading         path         telnetlib
_operator         easy_install         pathlib         tempfile
_osx_support         email         pathlib2         tensorboard
_overlapped        encodings         pathod         tensorflow
_pickle         engineio         pdb         termcolor
_pydecimal         ensurepip         peewee         terminaltables
_pyio         entrypoints         pep8         test       
_pytest         enum         perfmon         test_path
_random         errno         pickle         test_pycosat
_regex         et_xmlfile         pickleshare         test_regex
_regex_core         exampleproj         pickletools         testpath
_ruamel_yaml         fake_useragent         pika         tests
_sha1         fakeredis         pinyin         textwrap
_sha256         fastText         pip         theano
_sha3         fastcache         pipes         this
_sha512         fasttext_pybind         pkg_resources         threading
_signal         faulthandler         pkginfo         thulac
_sitebuiltins         fbmessenger         pkgutil         time       
_socket         filecmp         pkuseg         timeit
_sqlite3         fileinput         plac         timer
_sre         filelock         plac_core         tkinter
_ssl         flask         plac_ext         tldextract
_stat         flask_cors         plac_tk         tlz
_string         flask_jwt_simple        platform         token
_strptime         flask_socketio         playhouse         tokenize
_struct         fnmatch         plistlib         toolz
_symtable         fontTools         ply         tornado
_system_path         formatter         poplib         tqdm
_testbuffer         fractions         posixpath         trace
_testcapi         ftplib         pprint         traceback
_testconsole         functools         preshed         tracemalloc
_testimportmultiple         future         profile         traitlets
_testmultiphase         gast         progress         tty
_thread         gc         prompt_toolkit         turtle
_threading_local         genericpath         pstats         turtledemo
_tkinter         gensim         psutil         twilio
_tracemalloc         gerapy         pty         twisted
_warnings         getopt         pwiz         types
_weakref         getpass         py         typing
_weakrefset         gettext         py2neo         tzlocal
_win32sysloader         gevent         py4j         ujson
_winapi         glob         pyHook         unicodecsv
_winxptheme         glob2         py_compile         unicodedata
_yaml         graphviz         pyasn1         unittest
abc         greenlet         pyasn1_modules         urllib
absl         gridfs         pybind11         urllib3
adodbapi         grpc         pyclbr         urwid
afxres         gzip         pycodestyle         uu
aifc         h11         pycosat         uuid
alabaster         h2         pycparser         venv
anaconda_navigator        h5py         pycrfsuite         virtualenv
anaconda_project         hamcrest         pycurl         virtualenv_support
antigravity         hashlib         pydispatch         w3lib
appdirs         heapdict         pydivert         warnings
apscheduler         heapq         pydoc         wave       
argparse         hmac         pydoc_data         wcwidth
array         hpack         pyee         weakref
arrow         html         pyexpat         webbrowser
asn1crypto         html5lib         pyflakes         webencodings
ast         http         pygments         websocket
astor         humanfriendly         pygpu         websockets
astroid         hyperframe         pykwalify         werkzeug
asynchat         hyperlink         pylab         wheel
asyncio         idlelib         pylint         widgetsnbextension
asyncore         idna         pymongo         win2kras
atexit         imagesize         pymysql         win32api
attr         imaplib         pyodbc         win32clipboard
audioop         imghdr         pyparsing         win32com
automat         imp         pyperclip         win32con
autoreload         importlib         pyppeteer         win32console
babel         incremental         pyquery         win32cred
backports         inspect         pyreadline         win32crypt
base64         io         pyspark         win32cryptcon
bdb         ipaddress         pytest         win32ctypes
better_exceptions         ipykernel         pythoncom         win32event
bin         ipykernel_launcher         win32evtlog
binascii         ipython_genutils         win32evtlogutil
binhex         ipywidgets         pywin32_testutil        
binstar_client         isapi         pywinauto         win32gui
bisect         isort         pywintypes         win32gui_struct
bitarray         itertools         win32help
bleach         itsdangerous         qtawesome         win32inet
blinker         jdcal         qtconsole         win32inetcon
boto         jedi         qtpy         win32job
boto3         jieba         queue         win32lz
botocore         jinja2         queuelib         win32net
brain_builtin_inference        jmespath         quopri         win32netcon
brain_collections         joblib         random         win32pdh
brain_dateutil         json         rasa_addons         win32pdhquery
brain_fstrings         jsonmerge         rasa_core         win32pdhutil
brain_functools         jsonpath         rasa_core_sdk         win32pipe
brain_gi         jsonpickle         rasa_nlu         win32print
brain_hashlib         jsonschema         rasutil         win32process
brain_io         jupyter         re         win32profile
brain_mechanize         jupyter_client        readline         win32ras
brain_multiprocessing        jupyter_console         redis         win32rcparser
brain_namedtuple_enum        jupyter_contrib_core        regcheck         win32security
brain_nose         jupyter_contrib_nbextensions        regex        win32service
brain_numpy         jupyter_core        regutil         win32serviceutil
brain_pkg_resources        jupyter_highlight_selected_word        reprlib         win32timezone
brain_pytest         jupyter_nbextensions_configurator        requests         win32trace
brain_qt         jupyterlab         requests_file         win32traceutil
brain_re         jupyterlab_launcher        retrying         win32transaction
brain_six         jwt         rlcompleter         win32ts
brain_ssl         kaitaistruct         rmagic         win32ui
brain_subprocess        keras         rocketchat_API         win32uiole
brain_threading         keyring         rope         win32verstamp
brain_typing         keyword         ruamel_yaml         win32wnet
brotli         kiwisolver         run         win_inet_pton
browsercookie         klein         runpy         win_unicode_console
bs4         latex_envs         s3transfer         wincertstore       
bson         lazy_object_proxy         sched         winerror       
builtins         ldap3         schedule         winioctlcon       
bz2         lib2to3         schema         winnt
bz2file         libfuturize         scipy         winperf       
cProfile         libpasteurize         scrapy         winpty       
cachecontrol         lightgbm         scrapy_redis         winreg       
calendar         linecache         scrapy_splash         winsound
certifi         llvmlite         scrapyd_api         winxpgui
cffi         locale         scripts         winxptheme
cgi         locket         secrets         wordcloud
cgitb         lockfile         select         wrapper
chardet         logging         selectors         wrapt
chunk         lxml         selenium         wsgiref
classifier         lz4         service_identity         wsproto
click         lzma         servicemanager         xdrlib
cloudpickle         macpath         setuptools         xgboost
clyent         macropy         setuputils         xlrd
cmake         macurl2path         shelve         xlsxwriter
cmath         mailbox         shlex         xlwings
cmd         mailcap         shutil         xlwt
code         mako         signal         xml
codecs         markdown         simplegeneric         xmlrpc
codeop         markupsafe        simplejson         xxsubtype
collections         marshal         singledispatch         yaml
colorama         math        singledispatch_helpers zict
colorclass         matplotlib         sip         zipapp
coloredlogs         mattermostwrapper        sipconfig         zipfile       
colorhash         mccabe         sipdistutils         zipimport
colorsys         menuinst         site         zlib
commctrl         mimetypes         six         zmq
compileall         mistune         sklearn         zope

Enter any module name to get more help. Or, type “modules spam” to search
for modules whose name or summary contain the string “spam”.

在這裏插入圖片描述
在這裏插入圖片描述
運行結果:
在這裏插入圖片描述
print("--------test20190821.name--------------")
print(test20190821.name)
運行結果:
--------test20190821.name--------------
pythonLearning.test20190821


如果直接對test20190821.py直接做單元測試如下:

x=30
def printInfo():
print(30)
class MyClass():
data=“hello myclass”
def init(self,who):
self.name=who
def printName(self):
print(self.data,self.name)

if name==“main”:
x=printInfo()
print(x)
myclass=MyClass(“xiaopang”)
pn=myclass.printName()
print("----------------------------------------------")
print(pn)
print("-------myclass.data-------myclass.name----------")
print(myclass.data,myclass.name)

運行結果:

H:\ANACONDA\python.exe I:/ainlp/pythonLearning/test20190821.py
30
None
hello myclass xiaopang

None
-------myclass.data-------myclass.name----------
hello myclass xiaopang

Process finished with exit code 0

python 包

在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

發佈python模塊或程序

在這裏插入圖片描述
1.壓縮文件 使用disutils 裏面是源碼 : 如windows zip文件 Unix .tar.gz文件
2.自動解包或自動安裝可執行文件 編譯並製作
3.自包含的,不要求安裝的預備運行可執行程序
4.平臺相關的安裝程序
5.Python eggs 第三方模塊

完結

下一篇 使用disutils打包發佈模塊

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章