python用户交互与注释

1、input输入函数,name = input("请输入你的姓名"),将输入的内容赋值给name变量。

2、input会把你输入的数据不管是你输入的是数字还是字符串,都会转换成str格式。

3、格式化输出:

Name = input("Name:")
Age = input("age:")
City = input("city:")
info = """
-------------info is -----------
name is : %s
age is : %s
City is : %s
---------------------------------
""" % (Name,Age,City)
print(info)

个人感觉这个格式化输出在后续项目非常有用,对我的帮助很大。

猜你喜欢

转载自www.cnblogs.com/ZhRJ/p/11005674.html
今日推荐