分离输出(将输出与输入分开一行)

时间:2017-03-18 18:55:51

标签: python-3.x output

所以我制作了这段代码。 (不要考虑输入问题,它是程序的一部分。)

indexes = 1223314123
s = 'My hobby is computing'
now = input("Do you want to compress or decompress? ")
now = now.lower()
if now == 'compress':
    print(indexes)
    nows = input ("Do you want to decompress the file as well? If you do, please enter 'yes', or if you don't want to please enter 'no' ")
    nows = nows.lower()
    if nows == 'yes':
        print (s)
    elif nows == 'no':
        print ("Thank you for your time!")
    else:
        print ("Please try again!")
elif now == 'decompress':
    print(s)
    nowss = input ("Do you want to compress the file as well? If you do, please enter 'yes', or if you don't want to please enter 'no' ")
    nowss = nowss.lower()
    if nowss == 'yes':
        print (indexes)
    elif nows == 'no':
        print ("Thank you for your time!")
    else:
        print ("Please try again") 
else:
    print ("Please try again!")

输出就像这样

Do you want to compress or decompress? decompress
My hobby is computing
Do you want to compress the file as well? If you do, please enter 'yes', or 
if you don't want to please enter 'no' YEs
1223314123

你们中的任何一个人都知道一种方法可以使输出像这样 -

Do you want to compress or decompress? decompress
My hobby is computing

Do you want to compress the file as well? If you do, please enter 'yes', or if you don't want to please enter 'no' YEs
1223314123

因此,每当程序要求输入时,它就会被一条线与之前完成/输出的线分开。这是为了清晰的阅读,因为如果“索引”和“s”是更大的段落,如果想要再次找到它,那么很难找出输出的去向。

0 个答案:

没有答案