根据目录下的文件名生成SQL语句,文件名生成sql语句,[Python]代码#!
根据目录下的文件名生成SQL语句,文件名生成sql语句,[Python]代码#!
[Python]代码
#!/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)
相关内容
- 自动生成 unity_build.cpp,unity_build.cpp,自动生成 unity_b
- 用Python做Port Forwarding,pythonforwarding,recipe-48373
- 解析xml文本,xml文本,[Python]代码#
- RSA算法的简单实现,RSA算法简单实现,[Python]代码#!
- 用python+PYQT4写的一个俄罗斯方块游戏,pythonpyqt4,[Pytho
- python实现DES加密算法,pythondes加密算法,[Python]代码
- python获得磁盘剩余空间 statvfs,pythonstatvfs,[Python]代码
- python写的群发邮件系统 有点瑕疵 为了大家讨论下~~~,
- 整数/分数四则运算表达式分析并给出详细运算过程,四
- 仿内置用法 按key分组成嵌套字典,key嵌套,在日常开发
评论关闭