一、输出语句print()
##1、引号的使用
双引号 ""
单引号 ''
三引号 """...""", '''....'''
print(“hello world”)
print(‘hello python’)
print(“select * from tb01 where name=‘martin’”)
print(“MySQL\nRedis\nMongodb”)
print(""“Linux
Unix
Windows
MacOS”"")
print(“python自动化运维”)
##2、输出变量值
username = “Martin”
print(username)
print(“hello”, username)
##3、格式化输出
常用占位符:
%s字符串占位
username = "Martin"
password = "redhat"
age = 30
print("My name is ‘%s’" % username)
print("My name is '%s', My age is %s." % (username, age))
print("select * from tb01 where name='%s' and password='%s'" % (username, password))
%d 整数
print("The number is %d" % 100)
print("The number is %d" % 3.56634)
%f 浮点数
print("The number is %f" % 100)
print("The number is %f" % 3.1415926)
print("The number is %.4f" % 3.1415926)
%%%本身
number = 50
print("This is %d%%" % number)
##4、取消print自带的换行
print("hello world",end="")
print("hello python")