美文网首页
python学习

python学习

作者: m6ttl | 来源:发表于2018-10-07 11:54 被阅读0次

    # Python 学习的过程

    ## 现在的环境

    - Pycharm --用来写网站,调试程序

    - Jupyter notebook --用来爬虫、大数据分析

    - Typora --用来记录日志

    ## 学习markdown的语法

    # 标题1

    ## 标题2

    ### 标题3

    #### 标题4

    ##### 标题5

    ###### 标题6

    ###### 标题7

    ### 无序列表

    * 无序列表

    + 无虚列表

    - 无序列表

    ### 有序列表

    1. 有序的列表

    2. 列表2

    3. 列表3

    ### 引用

    > 应用1

    >

    > > 二级的应用

    >

    > 引用2

    > > > > 这个是好几级的引用了

    ---

    ***

    > 分割线

    ### 链接

    []()

    ### 表格

    | name | age  | sex  |

    | ---- | ---- | ---- |

    | 张飞 |      |      |

    | 关羽 | 20  | 男  |

    *斜体*

    **加粗的字体**

    ~~常用的基本上就这些了,如果还有一些常用的,可以跟我留言,~~

    常用的基本上就这些了,如果还有一些常用的,

    ==可以跟我留言,我补充上去,==

    我觉得图文并茂才是高效学习的正确姿势,但愿为你的学习带来帮助!

    ctrl + / 切换源码和效果模式

    888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

    这个是自动换行的

    ### 流程图

    ```mermaid

    graph LR

    A[方形] -->B(圆角)

        B --> C{条件a}

        C -->|a=1| D[结果1]

        C -->|a=2| E[结果2]

        F[横向流程图]

    ```

    ```mermaid

    graph TD

    A[方形] -->B(圆角)

        B --> C{条件a}

        C -->|a=1| D[结果1]

        C -->|a=2| E[结果2]

        F[竖向流程图]

    ```

    ```flow

    st=>start: 开始框

    op=>operation: 处理框

    cond=>condition: 判断框(是或否?)

    sub1=>subroutine: 子流程

    io=>inputoutput: 输入输出框

    e=>end: 结束框

    st->op->cond

    cond(yes)->io->e

    cond(no)->sub1(right)->op

    ```

    ```sequence

    对象A->对象B: 对象B你好吗?(请求)

    Note right of 对象B: 对象B的描述

    Note left of 对象A: 对象A的描述(提示)

    对象B-->对象A: 我很好(响应)

    对象A->对象B: 你真的好吗?

    ```

    ```mermaid

    %% 语法示例

            gantt

            dateFormat  YYYY-MM-DD

            title 软件开发甘特图

            section 设计

            需求                      :done,    des1, 2014-01-06,2014-01-08

            原型                      :active,  des2, 2014-01-09, 3d

            UI设计                    :        des3, after des2, 5d

      未来任务                    :        des4, after des3, 5d

            section 开发

            学习准备理解需求                      :crit, done, 2014-01-06,24h

            设计框架                            :crit, done, after des2, 2d

            开发                                :crit, active, 3d

            未来任务                              :crit, 5d

            耍                                  :2d

            section 测试

            功能测试                              :active, a1, after des3, 3d

            压力测试                              :after a1  , 20h

            测试报告                              : 48h

    ```

    ---------

    [] java

    [] python

    ### Typora快捷键

    | 快捷键      | 作用              | 快捷键      | 作用          |

    | ----------- | ------------------ | ------------ | -------------- |

    | Ctrl+1      | 一阶标题          | Ctrl+B      | 字体加粗      |

    | Ctrl+2      | 二阶标题          | Ctrl+I      | 字体倾斜      |

    | Ctrl+3      | 三阶标题          | Ctrl+U      | 下划线        |

    | Ctrl+4      | 四阶标题          | Ctrl+Home    | 返回Typora顶部 |

    | Ctrl+5      | 五阶标题          | Ctrl+End    | 返回Typora底部 |

    | Ctrl+6      | 六阶标题          | Ctrl+T      | 创建表格      |

    | Ctrl+L      | 选中某句话        | Ctrl+K      | 创建超链接    |

    | Ctrl+D      | 选中某个单词      | Ctrl+F      | 搜索          |

    | Ctrl+E      | 选中相同格式的文字 | Ctrl+H      | 搜索并替换    |

    | Alt+Shift+5 | 删除线            | Ctrl+Shift+I | 插入图片      |

    - [  ]

    - [X]

    -

    # pyechart

    ### 数据库连接

    ​ pycharm  SQLca.py

    ​ jupyter import sqlca

    地图文件被分成了三个 Python 包,分别为:

    全球国家地图: echarts-countries-pypkg (1.9MB)

    中国省级地图: echarts-china-provinces-pypkg (730KB)

    中国市级地图: echarts-china-cities-pypkg (3.8MB)

    直接使用python的pip安装:

    ```html

    pip install echarts-countries-pypkg

    pip install echarts-china-provinces-pypkg

    pip install echarts-china-cities-pypkg

    ```

    这里要提醒大家,一定要注意,安装完地图包以后一定要重启jupyter notebook,不然是无法显示地图的。

    安装完毕我们就可以直接画图了。

    pip install echarts-countries-pypkg

    ### pycharm永久激活

    激活

    复制到

    C:\P\PyCharm 2018.1\bin

      2)修改文件

    ​      上图中标记的文件,pycharm.exe.vmoptions  pycharm.exe.vmoptions两个文件

    ​      在文件的末尾加上

    -javaagent:C:\P\PyCharm 2018.1\bin\JetbrainsCrack-2.8-release-enc.jar

    ​        http://localhost:8888/?token=7c2467d686e339473c8ba57c329917deea5b0c0f6d2f65b1&token=7c2467d686e339473c8ba57c329917deea5b0c0f6d2f65b1

    ### mysql + dataframe + echart

    ```

    from pyecharts import Line3D

    from pyecharts import Geo

    from pyecharts import GeoLines, Style, Bar, Radar

    from pyecharts import Map

    from pyecharts import Gauge

    from pyecharts import Bar, Line, Scatter, EffectScatter, Grid, Kline

    import simplejson as json

    import numpy as np

    import pandas as pd

    from pandas import DataFrame

    conn = pymysql.connect(host = 'localhost',port = 3306,user = 'root',password = 'edit',db = 'mxonline3',charset='utf8')

    cursor = conn.cursor()

    sql_s = "select typen, count(*) f1, sum(order_m) as f2, sum(status) f3, max(order_m) f4, avg(order_m) f5 from myechart_ewsales group by typen"

    columns_s = ["typen", "f1", "f2", "f3", "f4", "f5"]

    #cursor.execute(sql)

    #result = cursor.fetchall()

    df = pd.read_sql(sql_s, conn, columns=columns_s)

    df

    ```

    ### 知识库的后续工作

    #### 1 、完善我发的课程

    以下都在 course\adminx.py 中修改

    * Uediter 问题(联动状态)

      联动没有弄好,先取消了

      ```

      # inlines = [LessonInline, CourseResourceInline]

      ```

    * 只能管自己的文章,找到简单方法了

    * 课程(用的自己email + 父教师email)

    * ```

      def queryset(self):

          qs = super(MyCourseAdmin, self).queryset()

          # qs = qs.filter( teacher__email=self.request.user.email )

          qs = qs.filter( Q(teacher__email=self.request.user.email) | Q(email=self.request.user.email))

          return qs

      def save_models(self):

          self.new_obj.email = self.request.user.email

          super().save_models()

      ```

    * 章节(用的关联)

      ```

      def queryset(self):

          if not self.request.user.is_superuser:  # 用户可查看自己的文章

              qs = super(LessonAdmin, self).queryset()

              # qs = qs.filter(course__name_)

              qs = qs.filter(Q(course__teacher__email=self.request.user.email) | Q(course__email=self.request.user.email))

          else: # 超级用户可查看所有数据

              qs = super(LessonAdmin, self).queryset()

          return qs

      ```

    * 视频(没有搞清楚视频外链)

    * 上传到 优酷 审核中

    * ```

      def queryset(self):

          if not self.request.user.is_superuser:  # 用户可查看自己的文章

              qs = super(VideoAdmin, self).queryset()

              # qs = qs.filter(course__name_)

              qs = qs.filter(Q(lesson__course__teacher__email=self.request.user.email) | Q(lesson__course__email=self.request.user.email))

          else: # 超级用户可查看所有数据

              qs = super(VideoAdmin, self).queryset()

          return qs

      ```

    * 上传材料

    * ```

      class CourseResourceAdmin(object):

          list_display = ['course', 'name', 'download', 'add_time']

          search_fields = ['course', 'name', 'download']

          list_filter = ['course__name', 'name', 'download', 'add_time']

          model_icon = 'fa fa-briefcase'

          def queryset(self):

              if not self.request.user.is_superuser:  # 用户可查看自己的文章

                  qs = super(CourseResourceAdmin, self).queryset()

                  # qs = qs.filter(course__name_)

                  qs = qs.filter(Q(course__teacher__email=self.request.user.email) | Q(course__email=self.request.user.email))

              else: # 超级用户可查看所有数据

                  qs = super(CourseResourceAdmin, self).queryset()

              return qs

      ```

    #### 2、专家组权限维护

    users_userprofile_groups

    #### 3、快速维护

    ### 4、考试系统

    ```

    http://119.97.214.18:5082/login.thtml  这个在线考试

    user: 韦政 pwd editedit

    ```

    ## 数据统计

    | 用户统计 | 正常 : 102 , 待审核 : 3 , 锁定 : 0                          |

    | -------- | ------------------------------------------------------------ |

    | 题库统计 | 题库数量 : 8 , 试题数量 : 526                                |

    | 试题统计 | 单选题 : 269 , 多选题 : 84 , 判断题 : 2 , 填空题 : 40 , 问答题 : 127 |

    | 试卷统计 | 试卷数量 : 6 , 进行中 : 0 , 已结束 : 6                      |

    | 资源统计 | 资源数量 : 0                                                |

    # jupyterLab

    ```

    cd C:\waterxp\python\jupyter\

    jupyter lab

    pip install jupyterlab  -i https://pypi.doubanio.com/simple

    ```

    ### password

    from notebook.auth import passwd

    passwd()

    token=f4f0efd71900af47d1424a231bf2241237e813734246437f

    ```

    'sha1:5f16bb13f186:cafac0d4ad19c4dec424479896846e6c748fb44e'

    ```

    passwd()

    ---------------------

    ### pandas

    #### 透视表

    df.pivot_table(index = 'A', columns = '', aggfunc = {'x1'.count(), 'x2'.sum()})

    # jupyter

    ### 我电脑的 kupyter notebook

    事实

    cmd 下没有 dashboard

    在 conda 环境下就有 dashboard

    #### 自启动 写入 autorun.bat

    ​ cd C:\waterxp\python\jupyter

    ​ jupyter notebook --no-browser --port 8003  --ip=0.0.0.0

    #### 加入自启动文件夹

    C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

    #### 设置密码 editedit

    * 执行

    C:\waterxp\python\jupyter>jupyter notebook --generate-config

    Overwrite C:\Users\vivian\.jupyter\jupyter_notebook_config.py with default config? [y/N]n

    * 生成

    C:\Users\vivian\.jupyter\jupyter_notebook_config.py

    * 算出密码

    passwd()

    Warning: Password input may be echoed.

    Enter password: >? editedit

    Warning: Password input may be echoed.

    Verify password: >? editedit

    Out[3]:

    'sha1:6006ec0f7c71:2c549a8f4d7272034d2422ec6a323507298ca969'

    * 设置密码

    C:\Users\vivian\.jupyter\jupyter_notebook_config.py

    -- 写入

    ```

    c.NotebookApp.ip='0.0.0.0'

    c.NotebookApp.password = u'sha1:6006ec0f7c71:2c549a8f4d7272034d2422ec6a323507298ca969'

    c.NotebookApp.open_browser = False

    c.NotebookApp.port =8003

    ```

    C:\Users\vivian\.jupyter\jupyter_notebook_config.json

    --修改

    ​    "password": "sha1:6006ec0f7c71:2c549a8f4d7272034d2422ec6a323507298ca969"

    * 重启、登录 OK-- editedit

    # 服务器自动执行

    cd

    python manage.py runserver 0.0.0.0127.0.01:8000

    ### jupyter主要快捷键

    4.Markdown cell和code cell这两种模式下的快捷键

    • Ctrl + Enter: run the cell

    • Shift + Enter: run the cell and select the cell below

    • Alt + Enter: run the cell and insert a new cell below

    • Ctrl + S: save the notebook

    5.编辑模式下的快捷键

    • Esc: switch to command mode

    • Ctrl + Shift + -: split the cell

    6.命令行模式下的快捷键

    • Enter: switch to edit mode

    • ↑ or k: select the previous cell

    • ↓ or j: select the next cell

    • y / m: change the cell type to code cell/Markdown cell

    • a / b: insert a new cell above/below the current cell

    • x / c / v: cut/copy/paste the current cell

    • dd: delete the current cell

    • z: undo the last delete operation

    • Shift + =: merge the cell below

    • h: display the help menu with the list of keyboard shortcuts

    ---

    ```

    jupyter contrib nbextension install --sys-prefix

    ```

    ```

    jupyter-dashboards-server --KERNEL_GATEWAY_URL=http://127.0.0.1:8889

    ```

    ### 代码组成

    这是一个非常另类的套装, 由以下几个部分组成

    [jupyter/dashboards](https://link.jianshu.com?t=https://github.com/jupyter/dashboards), notebook 插件将代码转化为可定制的 dashboard

    [dashboards_bundlers](https://link.jianshu.com?t=https://github.com/jupyter-incubator/dashboards_bundlers),notebook 插件将定制好的dashboard 输出到 server端

    [dashboards_server](https://link.jianshu.com?t=https://github.com/jupyter-incubator/dashboards_server),nodejs web框架,主要作用是与juypter server 通信展示只读功能的dashboard

    [kernel_gateway](https://link.jianshu.com?t=https://github.com/jupyter/kernel_gateway),一个中间的类似于代理的web框架,用于和dashboard server 通信

    [dashboards_setup](https://link.jianshu.com?t=https://github.com/jupyter-incubator/dashboards_setup) ,一套基于docker的服务范例,讲解各个服务如何配置

    作者:ClarkMMM

    链接:https://www.jianshu.com/p/e872aad33eeb

    ## JUPYTER DASHBOARD SERVER

    ### jupyter_dashboards_bundlers

    ```

    pip install jupyter_dashboards_bundlers -i https://pypi.doubanio.com/simple

    jupyter bundlerextension enable --sys-prefix --py dashboards_bundlers

    ```

    cd C:\waterxp\python\资料\dashboards_bundlers-master

    python setup.py build

    python setup.py install

    pip install

    - jupyter_dashboards 0.6.x

    - jupyter_dashboards_bundlers 0.8.x

    - ipywidgets 5.2.x

    - jupyter_declarativewidgets 0.6.x

    - matplotlib 1.5.x

    - Bokeh 0.11.x

    - Plotly 1.9.x

    pip install jupyter_dashboards  -i https://pypi.doubanio.com/simple

    - pip install  jupyter_dashboards_bundlers  -i https://pypi.doubanio.com/simple

    - ipywidgets 5.2.x

    - jupyter_declarativewidgets 0.6.x

    - matplotlib 1.5.x

    - Bokeh 0.11.x

    - Plotly 1.9.x

    # Jupyter Kernel Gateway

    ```

    # install from pypi

    pip install jupyter_kernel_gateway -i https://pypi.doubanio.com/simple

    # show all config options

    jupyter kernelgateway --help-all

    # run it with default options

    jupyter kernelgateway

    ```

    C:\Users\vivian\.jupyter\jupyter_kernel_gateway_config.py

    ```

    cd C:\waterxp\python\jupyter

    jupyter kernelgateway --KernelGatewayApp.ip=0.0.0.0 port=8003

    jupyter kernelgateway --KernelGatewayApp.port=8003

    [KernelGatewayApp] Jupyter Kernel Gateway at http://127.0.0.1:8889

    ```

    ```

    jupyter-dashboards-server --KERNEL_GATEWAY_URL=http://127.0.0.1:8888

    ```

    http://127.0.0.1:8003/nbextensions?nbextension=zenmode/main

    修改扩展设置

    from pyecharts import online

    import IPython.core.display as di;

    di.display_html('<script>jQuery(function() {if (jQuery("body.notebook_app").length == 0) \                { jQuery(".input_area").toggle(); jQuery(".prompt").toggle();}});</script>', raw=True)

    作者:大KKKK233

    链接:https://www.jianshu.com/p/bcd90bdaa87d

    來源:简书

    简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

    # word

    1 集中设置了8级标题,强调应用

    2 设置了默认字体 微软雅黑 + arial

    3. alt + shift + 左右 调整级别

    4. 无序号 3层序列

    5. 引用 直接用左边边框就可以实现

    6. 层级序号

    7. 默认首行缩进

    ----

    # Docker

    stevewei7777

    ![1538320018912](C:\Users\vivian\AppData\Roaming\Typora\typora-user-images\1538320018912.png)

    未果,他不响应1

    # node.js

    安装  node-v7.6.0-x64

    npm = Node.js的包管理工具(package manager)。

    1、Node.js简介

    简单的说 Node.js 就是运行在服务端的 JavaScript。Node.js 是一个基于 [Chrome V8](https://developers.google.com/v8/) 引擎的 JavaScript 运行环境。Node.js 使用了一个事件驱动、非阻塞式 I/O 的模型,使其轻量又高效。Node.js 的包管理器 [npm](https://www.npmjs.com/),是全球最大的开源库生态系统。

    在我安装的文件夹【c:\p\nodejs】下创建两个文件夹【node_global】及【node_cache】

    ```

    npm config set prefix "c:\p\nodejs\node_global"

    npm config set cache "c:\p\nodejs\node_cache"

    ```

    进入环境变量对话框,在【系统变量】下新建【NODE_PATH】,输入【c:\p\nodejs\node_global\node_modules】,

    将【用户变量】下的【Path】修改为【c:\p\nodejs\node_global】

    # 了解一下 pytorch

    算了,还是用 tf

    # 研究下自动启动 canda 下的jupyter

    %windir%\System32\cmd.exe "/K" C:\ProgramData\Anaconda3\Scripts\activate.bat C:\ProgramData\Anaconda3

    1. 编写  C:\ProgramData\Anaconda3\Scripts\activate_jupyter.bat

    2. @CALL "%~dp0..\Library\bin\conda.bat" activate %*

      cd C:\waterxp\python\jupyter

      jupyter notebook --no-browser --port 8003  --ip=0.0.0.0

    3. 快捷方式加入到 程序\开发 **"启动jupyter"**中

    # 研究下jupyter 的html 通过 TS4 转换后发布到网站

    ### ew 知识库中,课程显示

    显示成几天前修改

    学习人员显示昵称

    相关文章

      网友评论

          本文标题:python学习

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