2024-05-13 15:05:19 发布
网友
我想在Farhan Sadik和Snigdho上留个空间
我在间隔Name,Name2,Welcome上尝试了很多次,但是没有结果
Name
Name2
Welcome
您只需添加一个空格即可解决此问题:
Name + " " + Name2 + " " + third_variable
实际上,你把字符串连在一起,它们之间没有空格
你可以做:
print("Hi", name1, name2, welcome)
或:
print("Hi " + name1 + " " + name2 + " " + welcome)
print(Name + " " + Name2 + " " + "WELCOME")
输出:
Value of Name value of name2 WELCOME
If comma(,) is used in the place of " " it will also give the same output (as above)
上面的代码打印名称的值和空格(“”),然后再打印名称2和空格(“”)以及字符串“欢迎”
In the same way if you use \n in the space of " " you will get the output of the string or variable next to the \n in a new line. For example:
print(Name + "\n" + Name2 + "\n" + "WELCOME")
Value of Name Value of Name2 WELCOME
In the same way if \t is used in the place of \n it will print the variable or string next to it after a tab space, like:
您只需添加一个空格即可解决此问题:
实际上,你把字符串连在一起,它们之间没有空格
你可以做:
print("Hi", name1, name2, welcome)
或:
print("Hi " + name1 + " " + name2 + " " + welcome)
输出:
上面的代码打印名称的值和空格(“”),然后再打印名称2和空格(“”)以及字符串“欢迎”
输出:
输出:
相关问题 更多 >
编程相关推荐