|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- temp = input('请输入一个整数:')
- number = int(temp)
- while number:
- i = number - 1
- while i:
- print(' ', end = '')
- i = i - 1
- j = number
- while j:
- print('*', end = '')
- j = j - 1
- print()
- number = number - 1
复制代码
倒数第二句print()为什么会有换行的作用,我一开始写程序的时候没有加这一行,打印出来是在一行里面
- def print(self, *args, sep=' ', end='\n', file=None): # known special case of 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.
- """
- pass
复制代码
 看看print就知道了 默认 \n 换行符
 你给end传参的时候就把默认的 \n 换行符给覆盖了 自然不会换行了
|
|