
Python
Michael阿明
两个孩子的父亲,机械工程师,准备转行人工智能方向,一起加油吧!高举智慧,她就使你高升;怀抱智慧,她就使你尊荣。-- 箴言(4:8)
-
原创 正则表达式
文章目录1. ? 表示0个或者1个2. * 表示0个或者多个3. + 表示1个或者多个4. {} 设置匹配次数5. ^开头,$结尾,. 表示除\n外任意字符6. \w 表示字母,数字,下划线7. \s表示空格8. re.finditer1. ? 表示0个或者1个import redef text_match(text, pattern): if re.search(pattern, text): return "找到一个匹配!" else: return2020-12-02 21:04:42106
0
-
转载 Python发送文本邮件
在运行机器学习等需要大量计算的程序时,可以在报错或者程序运行完成时,发送邮件提醒。参考:Python发送邮件(文本邮件发送)# 运行完,发邮件提醒# 参考 https://blog.csdn.net/FransicZhang/article/details/83375299import smtplibfrom email.mime.text import MIMETextfrom email.header import Header mail_host = "smtp.qq.com"2020-08-16 16:44:03389
0
-
原创 3月14日 我用Python几十行代码为女朋友画了一个爱心
今天是个特殊的日子,圆周率日,哈哈!来对你爱的人表达爱吧!# -*- coding:utf-8 -*-# @Python Version: 3.7# @Time: 2020/3/14 13:14# @Author: Michael Ming# @Website: https://michael.blog.csdn.net/# @File: Valentine'sDay.py# @Re...2020-03-14 13:14:1411226
87
-
原创 python--从入门到实践--chapter 10 文件及错误
文件的读写:with open(filename, 'a', encoding='utf-8') as file:with :后面不必写close文件第二个参数:‘a’ 追加;‘w’ 写;‘r’ 读encoding = ‘utf-8’ 编码格式,中文的话一般写上enter = 'y'while enter == 'y': name = input("请输入你的名字:") ...2019-04-11 19:40:32478
0
-
原创 python--从入门到实践--chapter 11 代码测试unittest
编写的代码需要测试是否有Bugcity_functions.pydef city_country(city, country): return str(city) + ',' + str(country)city_country_unittest.pyimport unittestfrom city_functions import city_country as cccla...2019-04-19 00:08:43491
0
-
原创 python--从入门到实践--chapter 9 类
class Car(): def __init__(self,make,model,year): #构造函数 self.make = make self.model = model self.year = year self.odometer_reading = 0 def get_descriptive_name(self): long_name = str(self.y...2019-04-09 14:21:28515
0
-
原创 python--从入门到实践--chapter 12 pygame_Alien_Invasion
安装pygame包,把安装好的包copy一份到pycharm工程目录下,不然找不到pygame包抄一遍书上的代码:settings.pyclass Settings(): def __init__(self): self.screen_width = 1200 self.screen_height = 800 self.bg_co...2019-04-24 16:28:09704
2
-
原创 python--从入门到实践--chapter 15 16 17 生成数据/下载数据/web API
1.随机漫步random_walk.pyfrom random import choiceclass RandomWalk(): def __init__(self, num_points=5000): self.num_points = num_points self.x_value = [0] self.y_value = [0]...2019-05-01 22:59:37500
0
-
原创 利用python提取网站曲线图数据
文章目录数据1数据2数据1数据目标:曲线图F12,如图位置输入JSON.stringify(dataSeries.dataPoints)copy,粘贴到data.txt数据是一个列表,里面是多个字典编写程序如下:import json as jsdatafile = 'data1.txt'resultfile = 'result.txt'result = open...2019-09-10 21:22:564052
12