########## 输出 ########## authorizing... Welcome to the matrix Mr. Runsen.
input函数暂停运行,等待键盘输入,直到按下回车,输入的类型永远时字符串
a = input() 1 b = input() 2
print('a + b = {}'.format(a + b)) ########## 输出 ############## a + b = 12 print('type of a is {}, type of b is {}'.format(type(a), type(b))) ########## 输出 ############## type of a is <class 'str'>, typeofbis <class 'str'> print('a + b = {}'.format(int(a) + int(b))) ########## 输出 ############## a + b = 3
文件输入和输出
生产级别的 Python 代码,大部分 I/O 则来自于文件
这里有个in.text,完成worldcount功能。
Mr. Johnson had never been up in an aerophane before and he had read a lot about air accidents, so one day when a friend offered to take him for a ride in his own small phane, Mr. Johnson was very worried about accepting. Finally, however, his friend persuaded him that it was very safe, and Mr. Johnson boarded the plane.
His friend started the engine and began to taxi onto the runway of the airport. Mr. Johnson had heard that the most dangerous part of a flight were the take-off and the landing, so he was extremely frightened and
closed his eyes.
After a minute or two he opened them again, looked out of the window of the plane, and said to his friend。
"Look at those people down there. They look as small as ants, don't they?"
"Those are ants," answered his friend. "We're still on the ground."