python中的缩进符号_如何在Python输出中包装和缩进字典中的字符串?

我需要帮助包装我的输出文本。我需要打印参考书,即书+章+节数和实际诗句。不过,我需要的行包装为100个字符,然后与已打印的第一部分对齐。在

我有:from operator import itemgetter

logfile = "kjv.txt"

def bible_read():

fp=open(logfile,'r')

store=[]

while 1:

line=fp.readline()

if not line:

break

if line[-1:] == '\n':

line=line[:-1]

data0=line.split(' ')[0]

data1=line.split(' | ')[1]

data2=line.split('|')[2]

store.append({'LINE':data0,'Chap':data1,'Verse':data2})

fp.close()

#print store[1]

chapter = raw_input("Enter:")

if '-' in chapter:

book = chapter.split(" ")[0]

w = chapter.split(":")[0]

w = w.split(" ")[1]

x = chapter.split(":")[1]

x = x.split("-")[0]

x = int(x)

y = chapter.split("-")[1]

y = int(y)

#z = range[x,y]

#print book, w, x, y

chapR = range(x,y+1)

for i in chapR:

chapter = book + " " + w + ":" + str(i)

record = next((item["Verse"] for item in store if item["Chap"] == chapter), None)

print "%-10r %0r" % (chapter, record)

bible_read()

在本节中:

^{pr2}$

我需要能够打印出:'gen 1:2' ' And the earth was without form, and void; and darkness was upon

the face of the deep. And the Spirit of God moved upon the face of

the waters. '

所以我想让输出在100个字符处换行,然后缩进,这样它就和原来的缩进相匹配了。在

日志文件的一部分:2 | gen 1:3 | And God said, Let there be light: and there was light.

3 | gen 1:4 | And God saw the light, that it was good: and God divided the light from the darkness.

4 | gen 1:5 | And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.

5 | gen 1:6 | And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.

6 | gen 1:7 | And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so.

7 | gen 1:8 | And God called the firmament Heaven. And the evening and the morning were the second day.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值