将下述内容批量转换成指定的格式
复仇之魂,众神之王,魅惑魔女,变体精灵,水晶室女,流浪剑客,娜伽海妖,撼地神牛,隐形刺客,秀豆魔导师,熊德,剑圣月之骑士,矮人火枪手,巨魔战将,暗影萨满,钢背兽,熊猫酒仙,半人马酋长,赏金猎人,龙骑士,敌法师,黑暗游侠,全能骑士,沉默术士,树精卫士,谜团,光之守卫,熊战士,食人魔法师,修补匠,幻影长毛手,先知,山岭巨人,哥布林工程师,圣骑士,兽王,双头龙,练金术士,白虎,蛇法女妖,暗夜魔王,骷髅王,末日使者,地穴刺客,鱼人守卫,痛苦女王,骷髅射手,虚空假面,冥界亚龙,复仇电魂,食尸鬼,灵魂守卫,受折磨的灵魂,巫妖,死亡先知,恶魔巫师,剧毒术士,半人猛犸,死灵飞龙,混沌骑士,狼人,育母蜘蛛,幻影刺客,遗忘法师,潮汐猎人,痛苦之源,死灵法师,屠夫,裂魂人,地穴编织者,影魔,沙王,斧王,血魔,地狱领主,幽鬼,巫医,黑耀石毁灭者,术士,地卜师,暗影牧师,蝙蝠骑士,牛头人酋长
格式
arrList[intIndex++] ="复仇之魂"
arrList[intIndex++] ="众神之王"
arrList[intIndex++] ="魅惑魔女"
arrList[intIndex++] ="变体精灵"
arrList[intIndex++] ="水晶室女"
arrList[intIndex++] ="流浪剑客"
代码:
# -*- coding: utf-8 -*-
import sys
#hero=u"复仇之魂,众神之王,魅惑魔女,变体精灵,水晶室女,流浪剑客,娜伽海妖,撼地神牛,隐形刺客,秀豆魔导师,熊德,剑圣,月之骑士,矮人火枪手,巨魔战将,暗影萨满,钢背兽,熊猫酒仙,半人马酋长,赏金猎人,龙骑士,敌法师,黑暗游侠,全能骑士,沉默术士,树精卫士,谜团,光之守卫,熊战士,食人魔法师,修补匠,幻影长毛手,先知,山岭巨人,哥布林工程师,圣骑士,兽王,双头龙,练金术士,白虎,蛇法女妖,暗夜魔王,骷髅王,末日使者,地穴刺客,鱼人守卫,痛苦女王,骷髅射手,虚空假面,冥界亚龙,复仇电魂,食尸鬼,灵魂守卫,受折磨的灵魂,巫妖,死亡先知,恶魔巫师,剧毒术士,半人猛犸,死灵飞龙,混沌骑士,狼人,育母蜘蛛,幻影刺客,遗忘法师,潮汐猎人,痛苦之源,死灵法师,屠夫,裂魂人,地穴编织者,影魔,沙王,斧王,血魔,地狱领主,幽鬼,巫医,黑耀石毁灭者,术士,地卜师,暗影牧师,蝙蝠骑士,牛头人酋长"
hero=u"复仇之魂,众神之王,魅惑魔女,变体精灵,水晶室女,流浪剑客,娜伽海妖,撼地神牛,隐形刺客,秀豆魔导师,熊德,剑圣月之骑士,矮人火枪手,巨魔战将,暗影萨满,钢背兽,熊猫酒仙,半人马酋长,赏金猎人,龙骑士,敌法师,黑暗游侠,全能骑士,沉默术士,树精卫士,谜团,光之守卫,熊战士,食人魔法师,修补匠,幻影长毛手,先知,山岭巨人,哥布林工程师,圣骑士,兽王,双头龙,练金术士,白虎,蛇法女妖,暗夜魔王,骷髅王,末日使者,地穴刺客,鱼人守卫,痛苦女王,骷髅射手,虚空假面,冥界亚龙,复仇电魂,食尸鬼,灵魂守卫,受折磨的灵魂,巫妖,死亡先知,恶魔巫师,剧毒术士,半人猛犸,死灵飞龙,混沌骑士,狼人,育母蜘蛛,幻影刺客,遗忘法师,潮汐猎人,痛苦之源,死灵法师,屠夫,裂魂人,地穴编织者,影魔,沙王,斧王,血魔,地狱领主,幽鬼,巫医,黑耀石毁灭者,术士,地卜师,暗影牧师,蝙蝠骑士,牛头人酋长"
d=hero.split(u",")
i=0
for x in d:
s="arrList[intIndex++] ="
s+="\""+d[i]
s+="\""
print s
i=i+1
输出:
Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
arrList[intIndex++] ="复仇之魂"
arrList[intIndex++] ="众神之王"
arrList[intIndex++] ="魅惑魔女"
arrList[intIndex++] ="变体精灵"
arrList[intIndex++] ="水晶室女"
arrList[intIndex++] ="流浪剑客"
arrList[intIndex++] ="娜伽海妖"
arrList[intIndex++] ="撼地神牛"
arrList[intIndex++] ="隐形刺客"
arrList[intIndex++] ="秀豆魔导师"
arrList[intIndex++] ="熊德"
arrList[intIndex++] ="剑圣月之骑士"
arrList[intIndex++] ="矮人火枪手"
arrList[intIndex++] ="巨魔战将"
arrList[intIndex++] ="暗影萨满"
arrList[intIndex++] ="钢背兽"
arrList[intIndex++] ="熊猫酒仙"
arrList[intIndex++] ="半人马酋长"
arrList[intIndex++] ="赏金猎人"
arrList[intIndex++] ="龙骑士"
arrList[intIndex++] ="敌法师"
arrList[intIndex++] ="黑暗游侠"
arrList[intIndex++] ="全能骑士"
arrList[intIndex++] ="沉默术士"
arrList[intIndex++] ="树精卫士"
arrList[intIndex++] ="谜团"
arrList[intIndex++] ="光之守卫"
arrList[intIndex++] ="熊战士"
arrList[intIndex++] ="食人魔法师"
arrList[intIndex++] ="修补匠"
arrList[intIndex++] ="幻影长毛手"
arrList[intIndex++] ="先知"
arrList[intIndex++] ="山岭巨人"
arrList[intIndex++] ="哥布林工程师"
arrList[intIndex++] ="圣骑士"
arrList[intIndex++] ="兽王"
arrList[intIndex++] ="双头龙"
arrList[intIndex++] ="练金术士"
arrList[intIndex++] ="白虎"
arrList[intIndex++] ="蛇法女妖"
arrList[intIndex++] ="暗夜魔王"
arrList[intIndex++] ="骷髅王"
arrList[intIndex++] ="末日使者"
arrList[intIndex++] ="地穴刺客"
arrList[intIndex++] ="鱼人守卫"
arrList[intIndex++] ="痛苦女王"
arrList[intIndex++] ="骷髅射手"
arrList[intIndex++] ="虚空假面"
arrList[intIndex++] ="冥界亚龙"
arrList[intIndex++] ="复仇电魂"
arrList[intIndex++] ="食尸鬼"
arrList[intIndex++] ="灵魂守卫"
arrList[intIndex++] ="受折磨的灵魂"
arrList[intIndex++] ="巫妖"
arrList[intIndex++] ="死亡先知"
arrList[intIndex++] ="恶魔巫师"
arrList[intIndex++] ="剧毒术士"
arrList[intIndex++] ="半人猛犸"
arrList[intIndex++] ="死灵飞龙"
arrList[intIndex++] ="混沌骑士"
arrList[intIndex++] ="狼人"
arrList[intIndex++] ="育母蜘蛛"
arrList[intIndex++] ="幻影刺客"
arrList[intIndex++] ="遗忘法师"
arrList[intIndex++] ="潮汐猎人"
arrList[intIndex++] ="痛苦之源"
arrList[intIndex++] ="死灵法师"
arrList[intIndex++] ="屠夫"
arrList[intIndex++] ="裂魂人"
arrList[intIndex++] ="地穴编织者"
arrList[intIndex++] ="影魔"
arrList[intIndex++] ="沙王"
arrList[intIndex++] ="斧王"
arrList[intIndex++] ="血魔"
arrList[intIndex++] ="地狱领主"
arrList[intIndex++] ="幽鬼"
arrList[intIndex++] ="巫医"
arrList[intIndex++] ="黑耀石毁灭者"
arrList[intIndex++] ="术士"
arrList[intIndex++] ="地卜师"
arrList[intIndex++] ="暗影牧师"
arrList[intIndex++] ="蝙蝠骑士"
arrList[intIndex++] ="牛头人酋长"
>>>
感觉非常方便,同时也提高了效率,可以根据不同的需求做简单的修改
标签:术士,批量,python,arrList,++,intIndex,自动化,骑士,法师 From: https://blog.51cto.com/u_15990596/6632888