因此,对于家庭作业,我只需要制作一个我做过的ATM GUI,但是我想弄乱它并使之真正起作用,以便当我选择数字时它显示出一些不同。
print('\t\t\t\t|-------------------------------|')
print('\t\t\t\t| LCCS BANK LIMITED |')
print('\t\t\t\t| ATM Main Menu |')
print('\t\t\t\t| |')
print('\t\t\t\t| 1. Balance Enquiry |')
print('\t\t\t\t| 2. Cash Lodgement |')
print('\t\t\t\t| 3. Cash Withdrawal |')
print('\t\t\t\t| 4. Cash Transfer |')
print('\t\t\t\t| 5. Change PIN |')
print('\t\t\t\t| 6. Other Services |')
print('\t\t\t\t| |')
print('\t\t\t\t| 7. Exit |')
print('\t\t\t\t|-------------------------------|')
print('\t\t\t\t| |')
print('\t\t\t\t| CHOOSE AN OPTION >> |')
print('\t\t\t\t| |')
print('\t\t\t\t|-------------------------------|')
print('\t\t\t\t|-------------------------------|')
print('\t\t\t\t| LCCS BANK LIMITED |')
print('\t\t\t\t| ATM Main Menu |')
print('\t\t\t\t| |')
print('\t\t\t\t| 1. Balance Enquiry |')
print('\t\t\t\t| 2. Cash Lodgement |')
print('\t\t\t\t| 3. Cash Withdrawal |')
print('\t\t\t\t| 4. Cash Transfer |')
print('\t\t\t\t| 5. Change PIN |')
print('\t\t\t\t| 6. Other Services |')
print('\t\t\t\t| |')
print('\t\t\t\t| 7. Exit |')
print('\t\t\t\t|-------------------------------|')
print('\t\t\t\t| |')
option = input('\t\t\t\t| CHOOSE AN OPTION >> |')
print('\t\t\t\t| |')
print('\t\t\t\t|-------------------------------|')
问题是当我在打印之前使用输入时。我希望选择选项部分作为输入,但仍然打印GUI的其余部分,而无需键入任何内容,因此它看起来并不奇怪。多数民众赞成在下面的外壳,是python和程序设计的新手,谢谢帮助!,如果这看起来凌乱或令人困惑,我也很抱歉。
|-------------------------------|
| LCCS BANK LIMITED |
| ATM Main Menu |
| |
| 1. Balance Enquiry |
| 2. Cash Lodgement |
| 3. Cash Withdrawal |
| 4. Cash Transfer |
| 5. Change PIN |
| 6. Other Services |
| |
| 7. Exit |
|-------------------------------|
| |
| CHOOSE AN OPTION >> |
答案 0 :(得分:0)
如果我正确理解了这个问题,您希望光标保留在“选择选项>>”之后,而其余部分则在用户输入之前打印吗? 这是可能的,但也相当复杂。 Here与您的问题类似,但是您可以看到,它很快变得非常复杂。
如果要保持相对简单,可以执行以下操作:
print("""
\t\t\t\t|-------------------------------|
\t\t\t\t| LCCS BANK LIMITED |
\t\t\t\t| ATM Main Menu |
\t\t\t\t| |
\t\t\t\t| 1. Balance Enquiry |
\t\t\t\t| 2. Cash Lodgement |
\t\t\t\t| 3. Cash Withdrawal |
\t\t\t\t| 4. Cash Transfer |
\t\t\t\t| 5. Change PIN |
\t\t\t\t| 6. Other Services |
\t\t\t\t| |
\t\t\t\t| 7. Exit |
\t\t\t\t| |
\t\t\t\t| CHOOSE AN OPTION >> |
\t\t\t\t| |
\t\t\t\t|-------------------------------|
""")
option = input()
print("""
\t\t\t\t|-------------------------------|
\t\t\t\t| LCCS BANK LIMITED |
\t\t\t\t| ATM Main Menu |
\t\t\t\t| |
\t\t\t\t| 1. Balance Enquiry |
\t\t\t\t| 2. Cash Lodgement |
\t\t\t\t| 3. Cash Withdrawal |
\t\t\t\t| 4. Cash Transfer |
\t\t\t\t| 5. Change PIN |
\t\t\t\t| 6. Other Services |
\t\t\t\t| |
\t\t\t\t| 7. Exit |
\t\t\t\t| |
\t\t\t\t| CHOOSE AN OPTION >> {0} |
\t\t\t\t| |
\t\t\t\t|-------------------------------|
""".format(option))
这将给出以下输出:
|-------------------------------|
| LCCS BANK LIMITED |
| ATM Main Menu |
| |
| 1. Balance Enquiry |
| 2. Cash Lodgement |
| 3. Cash Withdrawal |
| 4. Cash Transfer |
| 5. Change PIN |
| 6. Other Services |
| |
| 7. Exit |
| |
| CHOOSE AN OPTION >> |
| |
|-------------------------------|
1
|-------------------------------|
| LCCS BANK LIMITED |
| ATM Main Menu |
| |
| 1. Balance Enquiry |
| 2. Cash Lodgement |
| 3. Cash Withdrawal |
| 4. Cash Transfer |
| 5. Change PIN |
| 6. Other Services |
| |
| 7. Exit |
| |
| CHOOSE AN OPTION >> 1 |
| |
|-------------------------------|