There are several ways to connect strings and strings
Answer: 5 kinds
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 #Restore standard output
result_str = result.getvalue()print("Connect with comma: ", result_str)
classMyclass:
def __str__(self):return'This is a Myclass Instance.'
my =Myclass()
s = s1 +str(my)print(s)
Recommended Posts