摘要:
回数是指从左到右读和从右到左读都是一样的数,请利用filter()滤掉非回数(打印出1000内所有回数) 方法一: def is_palindrome(n): return str(n) == str(n)[::-1] # str(n)[::-1]代表字符串从后往前读,也代表字符串的翻转 outpu 阅读全文
posted @ 2018-03-30 15:34
laosun0204
阅读(384)
评论(0)
推荐(0)
摘要:
lis = []for i in range(2, 101): j = 2 while j < i: if i % j == 0: break j += 1 # i % j == 0为假,j = j+1,然后在比较j < i,相当于else: j += 1 else: lis.append(i)pr 阅读全文
posted @ 2018-03-30 15:15
laosun0204
阅读(565)
评论(0)
推荐(0)
摘要:
def triangle(n): lis = [1] # 定义一个list while True: yield lis # 打印出该list lis = [lis[x] + lis[x + 1] for x in range(len(lis) - 1)] # 计算下一行中间的值(除去两边的1) li 阅读全文
posted @ 2018-03-30 11:51
laosun0204
阅读(130)
评论(0)
推荐(0)
摘要:
def fib(max_num): n, a, b = 0, 0, 1 while n < max_num: print(b) # 打印出来的就是裴波那契数列,从第三项开始,每一项都等于前两项之和 a, b = b, a+b n = n + 1 return 'done'fib(7)# 0,0,1 阅读全文
posted @ 2018-03-30 11:20
laosun0204
阅读(252)
评论(0)
推荐(0)
摘要:
import smtplib,osfrom email.mime.text import MIMEText #引入邮件文本处理模块from email.mime.multipart import MIMEMultipart #引入邮件附件处理模块import base64class SendMail 阅读全文
posted @ 2018-03-26 22:22
laosun0204
阅读(142)
评论(0)
推荐(0)
摘要:
import yagmail# 发送邮件,user为发送邮件的邮箱名,password为邮箱授权码,host为邮箱服务器,cc为抄送的邮箱# to为接收者的邮箱,多个邮箱用list,subject为邮件标题,contents为邮件正文,attachments为邮件带的附件(即生成的最新的报告)cla 阅读全文
posted @ 2018-03-25 16:35
laosun0204
阅读(138)
评论(0)
推荐(0)
摘要:
import pymysqlimport redisimport requestsimport hashlibimport osfrom conf.settings import REPORT_PATHclass MyMysql(object): def __init__(self, host, p 阅读全文
posted @ 2018-03-24 18:04
laosun0204
阅读(146)
评论(0)
推荐(0)
摘要:
MYSQL_INFO = { 'host':'127.0.0.1', # host不确定,到时候再改 'port':3306, # port不确定,到时候再改 'user':'guowang', # username不确定,到时候再改 'password':'123456', # password不 阅读全文
posted @ 2018-03-24 18:02
laosun0204
阅读(155)
评论(0)
推荐(0)
摘要:
import unittestfrom conf.settings import HOST_INFOfrom lib.tools import my_request, my_md5, my_mysqlclass Reg(unittest.TestCase): def setUp(self): sel 阅读全文
posted @ 2018-03-24 18:01
laosun0204
阅读(144)
评论(0)
推荐(0)
摘要:
import unittestfrom lib.tools import my_redis,my_request,my_mysqlfrom conf.settings import HOST_INFOclass Choujiang(unittest.TestCase): def setUp(self 阅读全文
posted @ 2018-03-24 16:30
laosun0204
阅读(148)
评论(0)
推荐(0)
浙公网安备 33010602011771号