Python 中 print() 函数; input()函数

print([object,...] [,seo = ‘ ’]  [, end = '\n'] [, file = sys.stdout])

sep: 表示输出的变量之间用什么字符串隔开,如果是缺省则默认为空格
end: 表示以某个字符串结尾,缺省为换行。
file: 指定了文本将要发送的文件、标准流或其它类似的文件的对象;默认为sys.stdout
格式化字符串 %d %s %(value; value)
其中 %4d 表示为输出结果为4个字符串,如输出结果不够四个字符串则用空格占位。
%04d 表示为输出结果为4个字符串,如不够四个字符串则用0占位。
for example:
在这里插入图片描述

input( prompt )

显示提示信息 prompt,是由用户输入内容
input( )函数的返回值是字符串类型,可通过int()函数将其装换为整数型
在这里插入图片描述

发布了36 篇原创文章 · 获赞 0 · 访问量 609

猜你喜欢

转载自blog.csdn.net/Corollary/article/details/105625277