根据目录下的文件名生成SQL语句,文件名生成sql语句,#!/usr/bin/p
文章由Byrx.net分享于2019-03-23 10:03:08
根据目录下的文件名生成SQL语句,文件名生成sql语句,#!/usr/bin/p
#!/usr/bin/python#coding=utf-8import osfrom datetime import datetimepath = "/Users/Demos/Desktop/ss/"id = 0#历遍指定文件夹for x in os.listdir(path): #只获取文件夹里面的JPG文件 if x.endswith(".jpg") or x.endswith(".JPG"): id += 1 #自增加ID title = x[:-4] #获取文件名作为标题 #根据ID位数在前面补0,小于10 补两个,大于10补一个 filename = {1:"00" + str(id), 2:"0" + str(id), 3:str(id)}[len(str(id))] times = datetime.strftime(datetime.now(), '%Y-%m-%d %H:%M:%S') os.rename(path + x, path + filename + '.jpg') #重命名文件 print "INSERT INTO `jtbc_superstar` VALUES(%d, '%s', 'common/upload/xphoto/%s.jpg', 'common/upload/photo/%s.jpg', '', 0, '%s', '|0|,|8|', 8, 0, 0, 0, 0); " % (id, title, filename, filename, times)
相关内容
- Python telnet服务器,pythontelnet服务器,import threa
- python htmldecode替换html实体,pythonhtmldecode,如下代码使用
- 抓取指定网页以及该网页上所有链接,抓取指定网页链
- windows下清理svn文件夹的python脚本,svnpython,# -*- coding
- Python 126邮箱自动登录程序,python126,import sys,
- Python汉字转拼音,python汉字拼音,# -*- coding
- 动态规划算法,计算单词距离,动态规划算法单词,#!/u
- Python 发email 带附件,python发email附件,from email.M
- 检测图片格式,,import osimp
- 硬盘中查找文件或内容,硬盘中查找文件,#coding:cp93
评论关闭