![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
香自寒来
梅花香自苦寒来
展开
-
python学习总结4-4
pythonpython基础 数据类型与变量 整数 浮点数 字符串 空值None 算术运算符 字符串:Unicode编码 ord()获取字符的整数表示 char()把编码转换成字符 list与tuple list列表 append添加元素到末尾:classmates.append('example') insert插入到指定位置:classmates.insert(1,'example') pop删除: 删原创 2021-04-04 08:52:32 · 159 阅读 · 1 评论 -
Python求回数
回数从左向右和从右向左读都是一样的数,606,999利用filter()求出回数由此我的想法是,判断左右的数是否相等就行def is_palindrome(n): L = [] for i in str(n): L.append(i) L1 = L[0:int((len(L)+1)/2)] L2 = L[int((len(L)-1)/2):] if set(L1) == set(L2): return n# 测试:outpu原创 2021-04-01 15:44:38 · 346 阅读 · 0 评论 -
Python求素数
Python素数判断Filter列出100以内素数Filter首先了解一下这个函数,Python内建的filter()函数用于过滤序列,用法与map()函数类似,接收一个函数一个序列,不通点在filter()把传入的函数作用于每一个元素,根据返回值是true函数false,来判断元素的去留#在一个list中只保留奇数def is_odd(n): return n % 2 == 1print(list(filter(is_odd,[1,2,3,4,5,6,7,8,9,10])))列出1原创 2021-04-01 12:29:16 · 1229 阅读 · 0 评论 -
一个神经元网络
from tensorflow import kerasimport numpy as np#构建模型model = keras.Sequential([keras.layers.Dense(units=1,input_shape=[1])])model.compile(optimizer='sgd',loss='mean_squared_error')#准备训练数据xs = np.array([-1.0,0.0,1.0,2.0,3.0,4.0],dtype=float)ys = np....原创 2021-03-05 20:27:57 · 154 阅读 · 0 评论 -
Python海龟画图集合
Python海龟画图集合1. 小猪佩奇2. 彩色螺旋线3. 太极4.美国队长盾牌1. 小猪佩奇# coding: utf-8import turtle as tt.screensize(400, 300)t.pensize(4) # 设置画笔的大小t.colormode(255) # 设置GBK颜色范围为0-255t.color((255,155,192),"pink...原创 2019-01-21 19:46:02 · 101398 阅读 · 0 评论 -
Python画图教程~海龟画图~turtle
Python画图教程1.运动控制2.画笔控制3.控制台控制1. 运动控制turtle.goto(x,y)画笔定位到坐标turtle.forward(d)向正方向走d距离turtle.backward(d)向负方向走d距离turtle.left(a)向左转a度turtle.right(a)向右转a度turtle.home()回到原点turtle...原创 2019-01-21 09:39:20 · 7659 阅读 · 0 评论 -
Python~打印日历~选择年月份~遍历
根据用户输入年月份来输出日历import calendarx = int(input('请输入年份:'))y = int(input('请输入月份:'))cal=calendar.month(x,y)print('以下输出'+str(x)+'年'+str(y)+'月的日历:')print(ca运行如下 遍历某一年的日历for循环import calenda...原创 2019-01-13 16:42:27 · 2794 阅读 · 0 评论 -
Python~九九乘法表for循环版while循环版
for循环版(range函数)print('九九乘法表for循环版')for i in range(1,10): for j in range(1,i): mut = j * i print('{}*{}={}'.format(j,i,mut),end='') print('')while循环版print('九九乘法表while循环...原创 2019-01-13 14:23:28 · 518 阅读 · 0 评论 -
Python爬取豆瓣榜单Top250~Request,re
1**. urllib.request.urlopen(url)打开URL参数指定字符串或者Request对象类型的URL链接地址 官方文档:https://docs.python.org/3/library/urllib.request.html2. re.findall()...原创 2019-01-18 11:48:29 · 793 阅读 · 0 评论