head_first python

Pypi网站  

https://pypi.python.org/pypi

账号keiweila 密码Gujinrong1234

 

 

1列表基本

Cast = [‘aaa’,’aa’];

len(cast)

Cast.append(‘bb’)

Cast.extend([‘cc’,11])

cast.insert(0,’111’)

cast.pop

Cast.remove(‘bb’)

 

2

for each_movie in movies :

print(each_movie)

 

Count =0

While count< len(movies):

print(movies[count])

count=count+1

 

3

If  isinstance(name.,list):

操作

else:

操作

 

4知道模块在计算机的位置

Python解释器就在这些位置上搜索代码

>>> import sys; sys.path

['', '/Users/gu/Documents', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages']

 

5创建一个包

setup(

    name='t1’,

    version='1.0.0',

    py_modules=['t1'],

    url='http://www.cnblogs.com/keiweila/',

    license='',

    author='gu',

    author_email='junvcheng@163.com',

    description='t2'

)

 

 

 

python3 setup.py sdist

将发布安装到你python本地副本

sudo python3 setup.py install

 

6python 会自动创建一个与模块同名的命名空间

import t1

t1.ss([1,2,3])

 

或者可用把指定的函数增加到当前的命名空间里面

from t1 import ss

ss([1,2,1])

 

7向pypi上传代码

命令行登录

python3 setup.py register

 

上传

python3 setup.py sdist upload

 

posted @ 2018-01-06 11:10  克维拉  阅读(206)  评论(0编辑  收藏  举报