python學習筆記--share your code vs module

添加註釋:

def func():
#this is a func
"""12321314
            2132144"""
print("func")

#或者3個”“” 註釋和代碼行放在一行可能會引起混淆


help(sys)
Help on built-in module sys:

DESCRIPTION
    This module provides access to some objects used or maintained by the
    interpreter and to functions that interact strongly with the interpreter.

sys模塊主要提供由解釋器使用維護的對象或者與解釋器有很緊密的函數


help(sys.path)
Help on list object:

class list(object)

sys.path是一個list對象

應該是類似於環境變量的東西吧 不是十分確定暫時


發佈模塊

1新建文件夾

2完成setup.py文件

3構建發佈文件 python3 setup.py sdist

4 安裝python模塊 sudo python3 setup.py install


兩種使用模塊的方法

1 import module調用需要 module.xxx

2 from module import xxx,此時xxx會覆蓋當前命名空間


python的模塊網址

pipy.python.org


向pypi上傳代碼

1 python3 setup.py register

2 python3 setup.py sdist upload


python的主命名空間 書上寫的是__main__

我用dir查看的主空間爲main


bif的命名空間爲 __builtins__

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