css檔案格式化指令碼的方法

來源:互聯網
上載者:User
這次給大家帶來css檔案格式化指令碼的方法,css檔案格式化指令碼的注意事項有哪些,下面就是實戰案例,一起來看一下。

#!/usr/bin/python# -*- coding: UTF-8 -*-import sys,osdef format(ddt):   ddt = ddt.replace('\n','')#去除換行   ddt=ddt.replace(';}','}').replace(';',';\n').replace('{','{\n').replace('}','\n}\n')#重新換行   lines = ddt.split("\n")#讀取全部換行內容   ddt=""   for line in lines  :       ddt=ddt+line.strip(' ')+"\n"#去除每行前面空格   return ddt.replace('{\n','{\n    ').replace(';\n',';\n    ') #空格整理for file in sys.argv:   if file!=sys.argv[0] and os.path.isfile(file)  and (str(file).split(".")[-1]).lower()=="css":      print u"正在讀取-",file      newfile = open(file,"r")      f=format(newfile.read())      newfile=open(file,'w')      newfile.write(f)      newfile.close()      print file,"-ok"

相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!

相關閱讀:

不同版本的vscdoe如何調試不同版本nodejs

Vuejs webp支援圖片的外掛程式開發

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.