python
文章平均质量分 57
iteye_9877
这个作者很懒,什么都没留下…
展开
-
文件的读写操作
刚学python,练习一下文件的读写,顺便记录一下代码import osdef build_or_open(): global f; global filename; filename=input("enter a file name:"); if os.path.exists(filename): print("文件...原创 2014-06-28 15:04:40 · 166 阅读 · 0 评论 -
python 递归打印指定路径下的所有文件
输入一个路径,显示文件下所有的子目录。import osdef list_all_path(path): if os.path.isfile(path): print(path); global count; count+=1 print(count); else: if o...原创 2014-06-28 22:01:24 · 258 阅读 · 0 评论 -
'ascii' codec can't decode byte 0xcc in position 0: ordinal not in range(128)(转)
在Django视图函数中经常出现类似于'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)的错误。 在解决错误之前,首先要了解unicode和utf-8的区别。 unicode指的是万国码,是一种“字码表”。而utf-8是这种字码表储存的编码方法。unico...原创 2014-12-22 15:42:21 · 327 阅读 · 0 评论 -
Python 使用htmlParser下载论坛歌曲
#encoding='GB2312'import requestsimport osfrom HTMLParser import HTMLParserprint '本脚本可以帮助您下载K歌之王中上传的歌曲'+'\n'bourl = "http://bbs.byr.cn/board/KaraOK"filepath= 'python/'headers = {'...原创 2014-12-23 15:02:06 · 118 阅读 · 0 评论 -
Python操作sqlite数据库的一些记录
Python 内置了sqlite的模块import sqlite3connection=sqlite3.connect('coachdata.sqlite')cursor=connection.cursor();'''cursor.execute("""create table athletes(id integer primary key autoincrement uni...原创 2014-12-28 21:36:36 · 120 阅读 · 0 评论 -
Python的图形化模块Tkinter的一些用法
#-*- encoding=UTF-8 -*-from Tkinter import *from ttk import *import os def get_sub_path(path): if os.path.isdir(path): for sub_path in os.listdir(path): get...原创 2014-12-30 21:23:30 · 127 阅读 · 0 评论 -
os.rename widnowsError [error 2] 错误的解决过程
今天需要对一系列的图片进行重命名。想到Python的listdir 和rename命令。觉得分分钟搞定的事情于是开始搞起图片的命名规则是icon_weather_day_00.png.重命名为d00.png第一版如下import os;import syspath="weather"for name in os.listdir(path): newNam...2015-01-04 16:57:25 · 955 阅读 · 0 评论 -
Python下载echo歌曲
最近在echo上面听到一首歌,一个6岁小女孩唱的“ I will always love you ”,简直是天籁,http://echo.kibey.com/sound/198168。你们也可以试试,真的很好听想下载的时候发现还要装什么客户端。不爽。。。简单分析了一下,结果就发现轻轻松松就下载了。。。。1:打开网页发现没有什么验证就可以直接听了,说明没什么验证,只要给定特定的u...2015-01-12 16:19:14 · 121 阅读 · 0 评论