php怎么调用css格式化,css文件格式化脚本的方法
這次給大家?guī)韈ss文件格式化腳本的方法,css文件格式化腳本的注意事項(xiàng)有哪些,下面就是實(shí)戰(zhàn)案例,一起來看一下。#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys,os
def format(ddt):
ddt = ddt.replace('\n','')#去除換行
ddt=ddt.replace(';}','}').replace(';',';\n').replace('{','{\n').replace('}','\n}\n')#重新?lián)Q行
lines = ddt.split("\n")#讀取全部換行內(nèi)容
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"
相信看了本文案例你已經(jīng)掌握了方法,更多精彩請(qǐng)關(guān)注php中文網(wǎng)其它相關(guān)文章!
相關(guān)閱讀:
總結(jié)
以上是生活随笔為你收集整理的php怎么调用css格式化,css文件格式化脚本的方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php7.0 cli,PHP-7.1 源
- 下一篇: php二维数组拆分成字符串,PHP二维数