We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第1种:+(加号)
s1 = 'hello' s2 = 'world' s = s1 + s2 print(s)
helloworld
2: 直接连接
s = "hello""world" print(s)
3:用逗号(,)连接,标准输出的重定向
from io import StringIO import sys old_stdout = sys.stdout result = StringIO() sys.stdout = result print('hello','world') sys.stdout =old_stdout # 恢复标准输出 result_str = result.getvalue() print("用逗号连接:",result_str)
用逗号连接: hello world
4:格式化
s = '<%s> <%s>' % (s1,s2) print('格式化:',s)
格式化: < hello > < world >
5: join
s = " ".join([s1,s2]) print("join连接:",s)
join连接: hello world
The text was updated successfully, but these errors were encountered:
#6
Sorry, something went wrong.
No branches or pull requests
第1种:+(加号)
2: 直接连接
3:用逗号(,)连接,标准输出的重定向
4:格式化
格式化: < hello > < world >
5: join
The text was updated successfully, but these errors were encountered: