随笔分类 -  python

摘要:题目大意: 计蒜客第6题泥塑课 基本思路: 不需要思路 代码如下: 阅读全文
posted @ 2018-04-09 20:51 愿~得偿所愿,不负时光 阅读(10234) 评论(0) 推荐(0)
摘要:转自:https://blog.csdn.net/zhoudaxia/article/details/23605263 在Python交互式解释器中输 入import this就会显示Tim Peters的The Zen of Python: >>> import this The Zen of Python, by Tim Peters Beautiful is better than ug... 阅读全文
posted @ 2018-04-09 20:19 愿~得偿所愿,不负时光 阅读(161) 评论(0) 推荐(0)
摘要:''' for循环: for i in range(x,y,dir): pass 首先这个区间是左闭右开 其次dir在省略的情况下默认为1,就是每次加一,也可以指定 python的数组: python中是没有数组的,但是可以用list来代替数组 一维数组: 方法一: arr=[0 for x in range(0,n)] 方法二: arr=[0]*10 方法一和方法二是等效的 二维数组... 阅读全文
posted @ 2018-04-08 20:14 愿~得偿所愿,不负时光 阅读(2200) 评论(0) 推荐(0)
摘要:题目大意: 就是弄一张图片在背景画布上移动,然后碰到边界就图片翻转并且反向移动 基本思路: 需要pygame常用的一些常用的函数,然后基本就是在背景画布上blit一张图片,然后移动就是先全刷成背景画布,然后在内存里绘制移动后位置的图片,然后整个绘制像素到背景画布上 阅读全文
posted @ 2018-03-22 10:55 愿~得偿所愿,不负时光 阅读(1004) 评论(0) 推荐(0)
摘要:# -*- coding: utf-8 -*- from PIL import Image codeLib = '''@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~i!lI;:,"^`'. '''#生成字符画所需的字符集 count = len(codeLib) def transform1(image_file): im... 阅读全文
posted @ 2018-03-15 19:58 愿~得偿所愿,不负时光 阅读(483) 评论(0) 推荐(0)
摘要:1.关于python的输入问题: 在2.x版本单行单输入input,单行多输入raw_input 在3.x版本中就已经没有raw_input,只有input,单行单输入多输入都可以。 类似2 3 4的输入,一般用 a, b, c = (int(x) for x in input().strip(). 阅读全文
posted @ 2018-03-10 20:25 愿~得偿所愿,不负时光 阅读(195) 评论(0) 推荐(0)
摘要:import urllib.requestimport json content=input("请输入需要翻译的内容:")url='http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule' data={} data['i 阅读全文
posted @ 2018-03-10 10:47 愿~得偿所愿,不负时光 阅读(816) 评论(0) 推荐(0)
摘要:开始学习爬虫,抓下网页源代码 import urllib.request response=urllib.request.urlopen("http://www.fishc.com") html=response.read() html=html.decode('utf-8') print(html 阅读全文
posted @ 2018-03-09 18:36 愿~得偿所愿,不负时光 阅读(78) 评论(0) 推荐(0)
摘要:import urllib.request#urllib.request.urlopen可以传入url或者Request对象#req=urllib.request.Request("http://placekitten.com/g/500/600")#response=urllib.request.urlopen(req)#response的geturl,info(),getcode()得到状态... 阅读全文
posted @ 2018-03-09 18:21 愿~得偿所愿,不负时光 阅读(329) 评论(0) 推荐(0)
摘要:os模块介绍: OS模块简单的来说它是一个Python的系统编程的操作模块,可以处理文件和目录这些我们日常手动需要做的操作。 os模块常用的函数以及变量 阅读全文
posted @ 2018-03-08 13:23 愿~得偿所愿,不负时光 阅读(287) 评论(0) 推荐(0)
摘要:import os import time #这里是需要文件所在的位置 source=['"C:\\My Documents"',"C:\\Code"] #转换完成之后放到的文件目录 target_dir="E:\\Backup" #判断有没有该文件,没有就创建一个 if not os.path.exists(target_dir): os.mkdir(target_dir) #o... 阅读全文
posted @ 2018-03-08 13:19 愿~得偿所愿,不负时光 阅读(198) 评论(0) 推荐(0)