日志文章

2020-6-29 aflfte2011

python变量的拼接

方法1:
name = 'aflfte'
print("hello"+ name) #输出hello aflfte

方法2:
name = 'aflfte'
robot_name = 'robot'
print("hello {} {}".format(name,robot_name)) #输出hello aflfte robot

方法3:
name = 'aflfte'
robot_name = 'robot'
print(f"hello {name} {robot_name}") #输出hello aflfte robot

方法4:
name = 'aflfte'
print("hello",name) #输出hello aflfte

« python方法定义 | python变量定义»