-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
s = 'road'
x = len(s)
print('The length of %s is %d' % (s,x)) ## The length of road is 4
from io import StringIO
import sys
old_stdout = sys.stdout
result = StringIO()
sys.stdout = result
print('The length of %s is %d' % (s,x))
sys.stdout = old_stdout
result_str = result.getvalue()
print('result_str',result_str,sep=':') ## result_str:The length of road is 4