永发信息网

如何用Python把单行文本处理成两行并对齐

答案:2  悬赏:20  手机版
解决时间 2021-04-09 06:38
  • 提问者网友:龅牙恐龙妹
  • 2021-04-08 17:24
如何用Python把单行文本处理成两行并对齐
最佳答案
  • 五星知识达人网友:你可爱的野爹
  • 2021-04-08 17:43
outputChords = ""
outputLyrics = ""
inBracket = False
for i in range(len(line)):
if line[i] == '[':
inBracket = True
outputChords = outputChords + " " * (max(0, len(outputLyrics.encode('gbk')) - len(outputChords.encode('gbk'))))
elif inBracket and line[i] == ']':
inBracket = False
elif inBracket and line[i] == '#':
pass
elif inBracket and str.isupper(line[i]):
outputChords = outputChords + line[i]
elif inBracket:
# DONT TRANSPOSE AND PUT IN OUTPUTCHORDS
outputChords = outputChords + line[i]
else:
outputLyrics = outputLyrics + line[i]
全部回答
  • 1楼网友:鱼芗
  • 2021-04-08 19:20
支持一下感觉挺不错的
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯