|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- for i in range(1,10):
- for j in range(1,i+1):
- print(j,'*',i,'=',j*i,end='')
- print('\n')
复制代码
麻烦问一下第4行代码,后面end=''的作用是什么
print打印默认会在结尾加换行符,不想让它换行就得指定 end=''
>>> help(print)
Help on built-in function print in module builtins:
print(*args, sep=' ', end='\n', file=None, flush=False)
Prints the values to a stream, or to sys.stdout by default.
sep
string inserted between values, default a space.
end
string appended after the last value, default a newline.
file
a file-like object (stream); defaults to the current sys.stdout.
flush
whether to forcibly flush the stream.
>>>
所以你要只是换行的话就用 print() 就可以了,print('\n') 会换两行
|
|