print() 和 input()

1. print()函数

(1) 输出字符串;

print('hello world!')

输出:hello world!

(2) 输出多个字符串,用逗号“,”隔开,遇到逗号会输出一个空格;

print('The quick brown fox', 'jumps over', 'the lazy dog')

输出:The quick brown fox jumps over the lazy dog

(3) 输出整数或计算结果;

print(100 + 200) or print(300)

输出:300

2. input()函数

name = input('please enter your name: ')
print('hello,', name)

  程序一运行,会首先打印出“please enter your name: ”,用户可以根据提示输入名字,得到hello, xxx的输出,如下图:

  

扫描二维码关注公众号,回复: 4347801 查看本文章

猜你喜欢

转载自www.cnblogs.com/Iris9195/p/10059960.html
今日推荐