我是靠谱客的博主 甜蜜眼睛,最近开发中收集的这篇文章主要介绍Python print() 函数Python print() 函数,觉得挺不错的,现在分享给大家,希望可以做个参考。

Python print() 函数

传递给函数的值称为参数。请注意,引号没有打印在屏幕上。它们只是表示字符串的起止,不是字符串的一部分。可以用这个函数在屏幕上打印出空行,只要调用 print() 就可以了,括号内没有任何东西。

1. example 1

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:Usersforeverstrong>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello World!")
Hello World!
>>> exit()

C:Usersforeverstrong>

2. example 2

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:Usersforeverstrong>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> width = 5
>>> width
5
>>> symbol1 = '*'
>>> symbol1
'*'
>>> print(symbol1 * width)
*****
>>> symbol2 = 'x'
>>> symbol2
'x'
>>> print(symbol2 * width)
xxxxx
>>> symbol3 = '0'
>>> symbol3
'0'
>>> print(symbol3 + (' ' * (width - 2)) + symbol3)
0   0
>>> print(symbol2 + (' ' * (width + 2)) + symbol2)
x       x
>>> print(symbol1 + (' ' * (width + 0)) + symbol1)
*     *
>>> exit()

C:Usersforeverstrong>

References

最后

以上就是甜蜜眼睛为你收集整理的Python print() 函数Python print() 函数的全部内容,希望文章能够帮你解决Python print() 函数Python print() 函数所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(38)

评论列表共有 0 条评论

立即
投稿
返回
顶部