字符串与字符串之间连接有几种方式
答:5种
s = "hello""world"
print(s)
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)
class Myclass:
def __str__(self):
return 'This is a Myclass Instance.'
my = Myclass()
s = s1 + str(my)
print(s)