今天发现python一个很好玩的模块 itchat ,可以很简单就实现一个自动回复 加根据不同的人回复不同消息 话不多说 上代码:#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Author : nanyu
# @File : 111.py
# @Time : 2019/4/17 14:14
# @Software: PyCharmimport itchat
import time
global num
global lis
# @itchat.msg_register(itchat.content.TEXT) #模块自带装饰器 可根据需要自行百度
@itchat.msg_register(itch...
1 >> m=[1,1,2,2,3];2 >> m3 4 m =5 611223 7 8 >> b=unique(m)910 b =
1112123使用unique函数;从而去掉重复元素,统计出现的元素及元素个数;例如: 1 >> a=[1,2,3,2;5,2,9,7;8,0,6,3];2 >> a3 4 a =5 61232 75297 88063 910 >> b=unique(a);
11 >> b
1213 b =
14150161172183195206217228239 原文:http://www.cnblogs.com/yuzhuwei/p/4101896.html
第一个案例首先开始来绘制你的第一个图表from pyecharts import Bar‘‘‘遇到不懂的问题?Python学习交流群:1004391443满足你的需求,资料都已经上传群文件,可以自行下载!‘‘‘
bar = Bar("我的第一个图表", "这里是副标题")
bar.add("服装", ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"], [5, 20, 36, 10, 75, 90])
# bar.print_echarts_options() # 该行只为了打印配置项,方便调试时使用
bar.render() # 生...
1 重新生成索引 如果某个索引值不存在就引入缺失值1from pandas import Series,DataFrame
2 import pandas as pd
3 import numpy as np
4 obj=Series([4.5,7.2,-5.3,3.6],index=[‘d‘,‘b‘,‘a‘,‘c‘])
5obj
67#重新生成索引
8 obj2=obj.reindex([‘a‘,‘b‘,‘c‘,‘d‘,‘e‘])
9 obj2 a使用method的ffill可以实现前向值填充,效果如下1#前向填充
2 obj3=Series([‘blue‘,‘purple‘,‘yellow‘],index=[0,2,4])
3 obj3.r...
def capitalize(self):str = ‘aGe‘print(str.capitalize())结果:Age结论:首字母大写,其他字母都小写def casefold(self):str = ‘AGE-age‘print(str.casefold())结果:age-age结论:首字母大写,其他字母都小写def center(self, width, fillchar=None):str = ‘AGE-age‘print(str.center(20,‘=‘))结果:======AGE-age=======结论:字符串str放在长为20的字符中,缺少的用fillchar字符来填充def count(self, sub, start=Non...
功能并非原创, 只是重复实现了 http://codecloud.net/python-control-128.html 中描述的功能. 实现功能: 通过给固定邮件地址发送命令(包含在主题中)的方式控制远程电脑实现相应功能(譬如关机等, 可以根据实际需要实现更复杂的功能)实现原理: 远程电脑不断(每隔10s)利用 python 脚本检查邮件服务器是否有新邮件, 如有则对邮件进行分析, 如果包含可执行命令, 则执行相应命令你需要的: 装有 PYTHON 的 PC; 最好两个邮箱(一个用于接收...
我们前面完成的客户纪录展示,只有4条,如果有上百条就不能在1页中全部展示了,那样是不人性化的.另外一次性取出来,数据量也比较大.假如现在有95条数据,我们想实现一个每页展示20条,那就分为5页.假如我们实现了,那么前端每一次请求就需要给后台提供参数了.这个参数就是告诉views里的视图函数我取第几页.需求分析: 95条,每页20条 第一次请求 返回20条,并且后端返回当前返回是第几页 ,所以第一次返回是1 点击下一页 1+1=2 ,把2...
前面的话: 1. 网页引用的bootstrap 中的表格,所以需要引入样式类 2. 第一次写文章,不喜勿喷。有不足的地方,可留言我改正,在此先谢过。HTML代码: <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>分页</title> <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css"></head><body><div class="container"><table class="table table-bordered"> <thead> <t...
https://www.cnblogs.com/hongten/p/hongten_python_function_annotation.html def f(ham: 42, eggs: int = ‘spam‘) -> "Nothing to see here":print("Annotations:", f.__annotations__)print("Arguments:", ham, eggs)#def关键字定义了函数f,在函数f中有两个参数:ham,eggs。
#其中ham没有默认值,而eggs是由默认值的,其默认值为‘spam‘.
#参数ham的注释部分为:42;参数eggs的注释部分为:int
# "Nothing to see here"是返...
本章学习内容:1、网页编码还原读取2、功能设计stuep1:网页编码还原读取本次抓取对象:http://www.cuiweijuxs.com/jingpinxiaoshuo/按照第一篇的代码来进行抓取:# -*- coding: UTF-8 -*-
from urllib import requestif __name__ == "__main__":chaper_url = "http://www.cuiweijuxs.com/jingpinxiaoshuo/"headers = {‘User-Agent‘: ‘Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0‘}req = reques...
接上篇文章新建Python环境变量配置文件:在宿主用户目录下vim .pystartup# Add auto-completion and a stored history file of commands to your Python# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is# bound to the Esc key by default (you can change it – see readline docs).# Store the file in ~/.pystartup, and set an environment variable to point# to it: “export PYTHONSTARTUP=~/...
1、os.path.abspath(path)获取绝对路径,实际上等于os.getcwd()+path2、os.path.basename(path)取path最后的文件或文件名。如果path以/结尾,那么就会返回空值;相对的有os.path.dirname(path),返回的是路径部分3、os.path.commonprefix(list)返回list中,所有path共有的最长的路径。4、os.path.exists(path)如果path存在返回True;如果path不存在,或者没有执行os.stat()的权限,或者已损坏的链接会返回False5、os.path.lexists(pa...
#可以用来修改配置文件参数 1# -*- coding:utf-8 -*- 2import os,sys3 old = sys.argv[1]4 new = sys.argv[2]5 file = sys.argv[3]6 file2 = sys.argv[3]7 tmp_file ="tmpfile" 8 f = open(file,"r")9 f2 = open(tmp_file,"r+")
10for line in f:
11if old in line:
12 line= str.replace(line,old,new)
13 f2.write(line)
14 f2.write(line)
15 f2.flush()
16f.close()
17f2.close()
1819os.remove(file)
2...
更多信息访问个人博客: http://cloudbps.com接到需求帮朋友监控一个信息网站,当该网站有相关的数据更新的时候发送信息到指定邮箱.下面是相关的python脚本,用到了httplib, time , sys ,smtplib模块#!/usr/bin/env python#coding=utf8import httplib, time
import sys
import smtplib
reload(sys)
sys.setdefaultencoding(‘utf8‘)
from email.mime.text import MIMEText
mailto_list=[‘sendmail@126.com‘]
mail_host="smtp.sina....
abc模块 / abc Module在定义抽象方法时,为了在初始化阶段就检测是否对抽象方法进行了重定义,Python 提供了 abc 模块。 1from abc import ABCMeta, abstractmethod2 3# Generate a abstract base obj - MyABC 4class MyABC(metaclass=ABCMeta):5#__metaclass__ = ABCMeta 6 @abstractmethod7def run(self):8pass 910class Foo(MyABC):
11def run(self):
12print(‘run‘)
1314 f = Foo()
15 f.run()第 4 行:...