求解
Topic sourceIn [3]: print?
Docstring:
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
Type: builtin_function_or_method
print函数默认的分隔符是' '
要去掉M前边的空格有几种方法,
1.不给print插入分隔符的机会
print('hello,%s' % name)
2.指定默认的分隔符为''
,注意 :虽然这两个单引号中间劈得很宽,像是有半个空格的样子,其实它俩中间真的没有其他字符混进去.
print('hello,',name,sep='')
- 1
独孤泠然July
name = input() print('hello,',name)
C:\Workspace> python hello.py Michael hello, Michael
第一段是文件,第二段是在命令行里运行文件,我想的是,我怎么可以把M前的空格去掉???