python 3.6基础:创建一个捕获用户输入的程序,并使用变量存储要打印的地址

loading...


0

请帮忙 :)

编写程序以从命令行提示中收集用户输入的两个完整地址(姓名,街道号,街道名称,城市,州和邮政编码) . 首先需要创建变量以将地址存储在变量中,然后创建相应的内置函数以从用户的地址中捕获输入 . 街道号码和邮编必须在系统中表示为数值 . 创建一个捕获用户输入的程序,并使用变量存储要打印的地址 .

我知道我需要使用 eval(input()) 将字符转换为数值 .

我有这个作为mac目前的python中的大纲,只需要输入信息但我仍然坚持“\ n”的含义 . 以及在哪里输入信息 .

#user input for first address
print ("\nEnter first address")
name1 = input("Name: ")
streetName1 = input("Street Name: ")
streetNumber1 = input("Street Number: ")
city1 = input("City: ")
#user input for first address
print ("\nEnter first address")
name1 = input("Name: ")
streetName1 = input("Street Name: ")
streetNumber1 = input("Street Number: ")
city1 = input("City: ")
state1 = input("State: ")
zip1 = input("Zip Code: ")
#user input for first address
print ("\nEnter second address")
name2 = input("Name: ")
streetName2 = input("Street Name: ")
streetNumber2 = input("Street Number: ")
city2 = input("City: ")
state2 = input("State: ")
zip2 = input("Zip Code: ")

打印两个地址

print ("\nFirst address is :")
print ("Name", name1)
print ("Street Name", streetName1)
print ("Street Number", streetNumber1)
print ("City", city1)
print ("State", state1)
print ("Zip Code", zip1)

print ("\nSecond address is :")
print ("Name", name2)
print ("Street Name", streetName2)
print ("Street Number", streetNumber2)
print ("City", city2)
print ("State", state2)
print ("Zip Code", zip2)
1回答

  • 0

    Python 3.x没有评估,你需要在获取和存储用户输入时使用int(),如下所示:

    streetNumber1 = int(input("Street Number: ")) zip1 = int(input("Zip Code: "))

loading...

评论

暂时没有评论!