print()函数查看帮助文件
>>> help(print) Help on built-in function print in module builtins: print(...) 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.语法格式
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)等价于
print(value1,value2 ...,valuen, sep=' ', end='\n', file=sys.stdout, flush=False) #sep中间用什么隔开 end 末尾加什么默认换行demo:
>>> a,b,c,*d=1,2,3,4,5,6 >>> print(a,b,c,d,sep='#',end='!') 1#2#3#[4, 5, 6]!>>>%格式化字符串 用%匹配参数,注意个数一一对应
>>> a=100 >>> "%d%%" % a '100%'