Pythonu用户交互

  1.input(),阻塞等待用户输入内容并敲回车。

1 #-*- encoding:utf-8 -*-
2 
3 name = input('请输入你的名字')
4 
5 age = input('请输入你的年龄')
6 
7 print(name, age)

  工作过程:先打印()内容,等待用户输入并敲回车,之后将用户输入信息赋值给变量,input出来的数据类型全部都是str字符串

猜你喜欢

转载自www.cnblogs.com/whylinux/p/9500564.html
今日推荐