1.读取用户输入内容
语法:input()
例:
name = input('你的名字是?)
print('你好'+name)
程序会等待用户输入名字后打印:你好(用户输入的名字)
注意:input接受的所有内容都是字符串类型。
2.格式化输出(占位符)
python中占位符为%(数据类型)
%s 字符串类型
%d 整数类型
%f 浮点数类型
使用方法:
a = 'str1'
b = 'str2'
s = ' %s hello %s'%(a,b)
print(s)
输出结果:
str1 hello str2
3.注释
单行注释
#
多行注释
'''
.................
.................
'''(三引号,单双引号都行。)
(用法等同于多行字符串)
语法总结:
input() #等待用户输入
% #占位符
# #注释