yihong0618/gitblog

Python存档

yihong0618 opened this issue · 10 comments

竟然才加上Python--2019.9.30

  1. lstrip
  2. partition 返回元祖(3个成员)

Python 打开一个不存在的文件往里写用

with open("abaaa.txt", "w+") as f:
    f.write("aaaaaaaaaaaaaaa")

django celery && celery 启动命令

python manage.py celery -A matrix_bgp worker --settings=
python manage.py celery beat --settings=
>>>str = 'runoob'
>>> str.center(20, '*')
'*******runoob*******'
>>> str.center(20)
'       runoob       '

pip version
19.2.3

nametuple尽量小写否则有坑。

python 打包上传pypi

首先安装上传工具
pip3 install -U pip setuptools twine

打包
python3 setup.py sdist # 会将项目打包到当前目录下面并生成相应的egg

上传
twine upload dist/* # 其实就是上传的dist目录下的zip包

python -c "import site; print(site.getsitepackages())"

>>>str = 'runoob'
>>> str.center(20, '*')
'*******runoob*******'
>>> str.center(20)
'       runoob       '

变量名不要覆盖内置类嘛~ 呵呵