题解 | #格式化输出(一)#
格式化输出(一)
https://www.nowcoder.com/practice/fe82dc48f4f04b2397a85fb1bdbe34a2
import sys
import re
str = sys.stdin.readline();
#使用strip()方法去掉字符串前后的换行符
#print('I am',str.strip('\n'),'and I am studying Python in Nowcoder!')
#使用replace()方法将换行符替换为空字符串
#print('I am',str.replace('\n',''),'and I am studying Python in Nowcoder!')
#使用正则表达式re.sub()方法将字符串中的换行符替换为空字符串
print('I am',re.sub("\n", "", str),'and I am studying Python in Nowcoder!')
查看10道真题和解析

