输入输出操作

2019-12-31  本文已影响0人  arthur_wang_73

PS:纸上得来终觉浅,绝知此事要躬行。人生苦短,我学python。

注意事项:

输入输出

输入命令:

input()
input("请输入数据:")
int(input())
a,b,c=int(input()).split()

按照字符串的方式,接收整行的数据。
注意事项:
1, 类型转换: a=int(input()) ...
2,一行有多个输入需要分开时: a, b,c =int(input()).split()
输入 3 4 5 回车,a,b,c 分别得到 3, 4, 5的整形值。

输出命令:

print()
print("三角形边长:", a,b,c,end=" ")
print("area of the triangle:{:.4f}".format( area))

print() 输出是一个整行。如果需要两个print在同一行输出,就需要在前一个print中是用 end=" ",这样本行就不换行啦
格式输出需要使用大括号 {:.4f} 对输出量需要 使用 .format(area)
.format()是对字符串对象的方法,如果要输出多个格式数据,就需要在括号中加上其他的变量。

上一篇 下一篇

猜你喜欢

热点阅读