rokevin
移动
前端
语言
  • 基础

    • Linux
    • 实施
    • 版本构建
  • 应用

    • WEB服务器
    • 数据库
  • 资讯

    • 工具
    • 部署
开放平台
产品设计
  • 人工智能
  • 云计算
计算机
其它
GitHub
移动
前端
语言
  • 基础

    • Linux
    • 实施
    • 版本构建
  • 应用

    • WEB服务器
    • 数据库
  • 资讯

    • 工具
    • 部署
开放平台
产品设计
  • 人工智能
  • 云计算
计算机
其它
GitHub
  • 静态强类型

    • Java
    • Kotlin
    • Dart
    • Swift
  • 静态弱类型

    • C语言
    • C++
  • 动态强类型

    • Python
  • 动态弱类型

    • JavaScript
    • PHP

Python

官方网站

https://www.python.org

文档

官方文档 https://docs.python.org/zh-cn/3/index.html

https://docs.python.org/zh-cn/3/library/datetime.html#strftime-and-strptime-behavior

安装 常见问题

模块

paramiko ssh使用markdownGitPython

开发规范约定

Python PEP8 编码规范中文版

https://blog.csdn.net/ratsniper/article/details/78954852

https://www.python.org/dev/peps/

https://blog.csdn.net/ratsniper/article/details/78954852

教程

python3 教程

https://www.runoob.com/python3

http://www.runoob.com/python/python-install.html

爬虫

http://www.cnblogs.com/fnng/p/3576154.html

Mac中升级Python2.7到Python3.5步骤

https://blog.csdn.net/u014057054/article/details/52446170

话题

https://www.zhihu.com/topic/19552832/top-answers

学习资源

https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_10124533352013411761%22%7D&n_type=1&p_from=4

错误

编码错误

SyntaxError: Non-ASCII character '\xe6' in file 打印日期.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Python在默认状态下不支持源文件中的编码。解决方案有如下三种:

一、在文件头部添加如下注释码:

coding=<encoding name> 例如,可添加# coding=utf-8

二、在文件头部添加如下两行注释码:

#!/usr/bin/python

# -*- coding: <encoding name> -*- 例如,可添加# -*- coding: utf-8 -*-

# python3中默认使用 utf-8编码

三、在文件头部添加如下两行注释码:

#!/usr/bin/python

# vim: set fileencoding=<encoding name> : 例如,可添加# vim: set fileencoding=utf-8 :

python 花图工具

Matplotlib 和 pyecharts

pyecharts==0.5.11
pyecharts-javascripthon==0.0.6
pyecharts-jupyter-installer==0.0.3
pyecharts-snapshot==0.1.10

如果提示 没有module jiaji2的时候,设置下环境变量

执行命令,查看对应的地址,把地址加到环境变量中

pip install jiaji2

进入.bashrc

export PYTHONPATH=$PYTHONPATH:"/usr/local/lib/python3.6/site-packages"

source .bashrc

它的安装过程中要去 github 下载一个包,而 github release 文件放在亚马逊 aws 上(被墙了)。解决方法是借助淘宝镜像 (http://cnpmjs.org/downloads https://npm.taobao.org/mirrors/phantomjs/) 安装,输入以下命令:

PHANTOMJS_CDNURL=https://npm.taobao.org/mirrors/phantomjs/ npm install phantomjs-prebuilt

https://github.com/xhlwill/blog/issues/11

如果提示"No phantomjs found in your PATH. Please install it!则" 保存图片需要安装

npm install -g phantomjs-prebuilt

如果报错安装下面命令

npm install phantomjs-prebuilt@2.1.14 --ignore-scripts

centos 7

python(>=2.7)
requests==2.18.4
mysql-connector==2.2.9
pyecharts==0.5.11

保存图片需要安装phantomjs-prebuilt
下载地址http://www.bzip.org/downloads.html

安装bzip2

yum -y install bzip2

解压工具包

tar -xjvf phantomjs-2.1.1-linux-x86_64.tar.bz2

设置环境变量,打开~/.bashrc添加

export PATH=$PYTHON/bin:$PHANTOMJS/bin:$PATH

退出并保存

source .bashrc 

截图出现乱码:

https://blog.csdn.net/hacker_Lees/article/details/77231252


官方网站 http://pyecharts.org/#/zh-cn/technical

脚本

# -*- coding: utf-8 -*-
# !/usr/bin/env python

from __future__ import unicode_literals

from pyecharts import Bar

bar = Bar("")
bar.add("运单总价",
        ["2019-02-15", "2019-02-16", "2019-02-17", "2019-02-18", "2019-02-19", "2019-02-20", "2019-02-21", "2019-02-22",
         "2019-02-23", "2019-02-24"]
        , [6325.00, 22482.00, 95695.00, 151155.00, 151460.00, 222685.00, 286581.01, 431928.02, 436052.00, 52230.00],
        is_label_show=True)

# bar.print_echarts_options() # 该行只为了打印配置项,方便调试时使用
bar.render(path='./tmp.png', template_name='./test.html')  # 生成本地 HTML 文件

python 发送邮件

# !/usr/bin/env python
# coding=utf-8

import smtplib

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage

msg_from = 'xxx1@qq.com'  # 发送方邮箱
passwd = 'xxx'  # 填入发送方邮箱的授权码
msg_to = 'xxx2@qq.com,xxx3@qq.com'  # 收件人邮箱
cs_to = 'xxx4@qq.com,xxx5@qq.com'  # 抄送

def send():
    subject = "python邮件测试"  # 主题  alt="imageid"
    msg = MIMEMultipart('related')
    content = MIMEText('<html>'
                       '<body>'
                       '你好'
                       '<img src="cid:imageid">'
                       '干线'
                       '<img src="cid:imageid1"'
                       '</body>'
                       '</html>',
                       'html',
                       'utf-8')  # 正文
    # msg = MIMEText(content)
    msg.attach(content)
    msg['Subject'] = subject
    msg['From'] = msg_from
    # 此处需要字符串,下面发送邮件地方需要列表,可以使用msg_to.split(',')转成列表
    msg['To'] = msg_to 
    # 此处同上
    msg['Cc'] = cs_to

    # 第一张图片

    file = open("./xxx.jpeg", "rb")
    img_data = file.read()
    file.close()

    img = MIMEImage(img_data)
    img.add_header('Content-ID', 'imageid')
    msg.attach(img)

    # 第二张图片

    file1 = open("./xxx.png", "rb")
    img_data1 = file1.read()
    file1.close()

    img1 = MIMEImage(img_data1)
    img1.add_header('Content-ID', 'imageid1')
    msg.attach(img1)

    try:
        s = smtplib.SMTP_SSL("smtp.mxhichina.com", 465)  # 阿里邮件服务器及端口号
        s.login(msg_from, passwd)
        # 发送给多人、同时抄送给多人,发送人和抄送人放在同一个列表中  
        s.sendmail(msg_from, msg_to.split(",") + cs_to.split(","), msg.as_string())
        print("发送成功")
    except:
        print("发送失败")
    finally:
        s.quit()


send()

https://blog.csdn.net/captain_mxd/article/details/79447666

pip

如何自动生成和安装requirements.txt依赖

requirements.txt可以通过pip命令自动生成和安装

生成requirements.txt文件

pip freeze > requirements.txt

安装requirements.txt依赖

pip install -r requirements.txt

pip3更新问题

python3 -m pip install --upgrade pip

资料

https://www.jianshu.com/p/0d05b01bd131 https://blog.csdn.net/u013634961/article/details/38826189 https://blog.51cto.com/m51cto/2051945 https://blog.csdn.net/qq_41235053/article/details/81879329 https://blog.csdn.net/tanya_girl/article/details/71218161 https://www.jianshu.com/p/f8c43e25c02e https://github.com/qiwsir/python-1 https://www.jianshu.com/p/9c6ae64a1bd7?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation https://www.jianshu.com/p/59e5662b8fc3?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation https://blog.csdn.net/captain_mxd/article/details/79447666 https://blog.csdn.net/qq_39241986/article/details/80628025 https://blog.51cto.com/cloumn/detail/13 https://blog.csdn.net/dou3516/article/details/82912796 https://www.python.org/ https://pypi.org/project/aliyun-python-sdk-core-v3/

最近更新:: 2025/10/22 15:36
Contributors: luokaiwen