import random
# Main menu.
print('**** Welcome to the Pick-3, Pick-4 lottery number generator! ****\n\
\nSelect from the following menu:\n\n1. Generate 3-Digit Lottery number\
\n2. Generate 4-Digit Lottery number\n3. Exit the Application\n')
# Holds the user's selection in memory.
userInput = int(input())
# If-else statements performs proper operation for the user.
if userInput == 1:
print('\nYou selected 1. The following 3-digit lottery number was generated:\
\n\n')
for i in range(3):
print(random.randrange(1, 10), end = '')
if userInput == 2:
print('\nYou selected 2. The following 4-digit lottery number was generated:\
\n\n')
for i in range(4):
print(random.randrange(1, 10), end = '')
if userInput == 3:
print('\nYou selected 3.\n\nThanks for trying the Lottery Application.\
\n\n*********************************************************')
SystemExit这是我输入1时得到的输出,例如:
您选择了% 1。已生成以下3位数字的彩票号码:
657%
我怎样才能去掉这个百分号?我正在使用VSCode进行编译。谢谢。
发布于 2020-05-29 10:04:52
%不是从Python输出的。这是您的shell告诉您没有尾随换行符(或者,更确切地说,是光标停留在非零列偏移量上;当没有捕获或重定向输出时,您的shell无法看到它运行的程序写入了什么输出,但它可以查询终端以获取光标位置)。退出前的最后一张照片不应该有end=''。
https://stackoverflow.com/questions/62077416
复制相似问题