Getting Started lesson one: a simple user interaction program
1 name = input ("") #python3.x in replaces the Input_raw in python2.x 2 age = Int (input (#此处若不加int语句:)) , the computer is recognized as a string when entered, and in order to ensure that the computer is recognized as a number, the user can also enter a numeric unexpected character. int = integer meaning 3 job = input ("")4 salary = Input ("")
Here are three ways to output:
1 info = 2 ----Info of%s----#% to formatted string, S = string, d = digit
3 name:%s 4 age:%d 5 job:%s 6 salary:%s 7 % ( Name, name, age, job, salary) 8 print (info)
""" ----Info of {_name}----name: {_name}age: {_age}job: {_job}salary: {_salary} "" ". Format (_name = name, = Age , = job, = salary)print (Info2)
""" ----Info of {0}----Name: {0}age: {1}job: {2}salary: {3} """ . Format (name, age, job, salary) Print (INFO3)
The above three methods of writing output the same, the following example:
Python Learning Note one: a simple interactive program