美文网首页
Python初学笔记

Python初学笔记

作者: ADTQoo | 来源:发表于2016-03-03 15:33 被阅读0次

    s+##Python 标识符

    在python里,标识符有字母、数字、下划线组成。

    在python中,所有标识符可以包括英文、数字以及下划线_,但不能以数字开头。

    python中的标识符是区分大小写的。

    以下划线开头的标识符是有特殊意义的。以单下划线开头_foo的代表不能直接访问的类属性,需通过类提供的接口进行访问,不能用"from xxx import *"而导入;

    以双下划线开头的(__foo)代表类的私有成员;以双下划线开头和结尾的(foo)代表python里特殊方法专用的标识,如init()代表类的构造函数。

    多行语句
    Python语句中一般以新行作为为语句的结束符。

    但是我们可以使用斜杠( \)将一行的语句分为多行显示,如下所示:

    total=item_one+\

    item_two+\

    item_three

    语句中包含[], {} 或 () 括号就不需要使用多行连接符。如下实例:

    days=['Monday','Tuesday','Wednesday','Thursday','Friday']

    Models


    remember the three-step guide to making model changes:
    1.Change your models (in models.py ).
    2.Run python manage.py makemigrations to create migrations for those changes
    3.Run python manage.py migrate to apply those changes to the database.

    连接Django与nigixpython
    uwsgi -s 127.0.0.1:8001 -w yushan2.wsgi

    起celery
    (export C_FORCE_ROOT=true)
    celeryd -A yushan2 -l info
    !!! 异步任务修改后 要重启celery,因为程序实例在内存里
    !!! 异步任务调用时 需要加 .delay

    git pull过之后同步静态文件
    python manage.py collectstatic

    linux

    查看所有权限 ls -l
    添加权限 chmod +x ssh_active2
    查看定时任务 crontab -l

    相关文章

      网友评论

          本文标题:Python初学笔记

          本文链接:https://www.haomeiwen.com/subject/xrkbkttx.html