Created
January 6, 2013 08:51
-
-
Save friskfly/4466125 to your computer and use it in GitHub Desktop.
python 批量生成西祠频道option选择标签
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import re | |
string = ''' | |
TagDict.Add "@胡同口@","@1386@" | |
TagDict.Add "@时尚@","@1357@" | |
TagDict.Add "@汽车@","@1336@" | |
TagDict.Add "@旅游@","@1378@" | |
TagDict.Add "@家居@","@1396@" | |
TagDict.Add "@数码@","@1242@" | |
TagDict.Add "@都市@","@1276@" | |
TagDict.Add "@媒体@","@1183@" | |
TagDict.Add "@人文@","@1208@" | |
TagDict.Add "@文艺@","@1254@" | |
TagDict.Add "@娱乐@","@1176@" | |
TagDict.Add "@体育@","@1307@" | |
TagDict.Add "@情感@","@1231@" | |
TagDict.Add "@院校@","@1265@" | |
TagDict.Add "@囧友@","@1301@" | |
TagDict.Add "@美食@","@1278@" | |
TagDict.Add "@职场@","@2423@" | |
TagDict.Add "@摄影@","@2433@" | |
TagDict.Add "@亲子@","@2436@" | |
TagDict.Add "@花嫁@","@2512@" | |
TagDict.Add "@购物@","@2516@" | |
TagDict.Add "@教育@","@2672@" | |
TagDict.Add "@宠物@","@2676@" | |
''' | |
re = re.compile(r"@(.*?)@.*@(.*?)@") | |
find = re.findall(string) | |
for i in find: | |
str = '''{t}<option value="{id}" <% if fi_clubid="{id}" then response.write("selected=""selected""") end if %>>{name}</option>''' | |
str = str.replace("{t}", "\t\t\t\t\t") | |
str = str.replace("{id}", i[1]) | |
str = str.replace("{name}", i[0]) | |
print str |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment