美文网首页
廖雪峰 | 1.0 Python输入输出

廖雪峰 | 1.0 Python输入输出

作者: 苦哈哈的柠檬水 | 来源:发表于2022-04-09 22:38 被阅读0次

输出

print()执行并打印括号内信息
1,打印字符串

>>>print('hello, world')
>>>print("hello, world")
hello, world
>>>print('The quick brown fox', 'jumps over', 'the lazy dog')
The quick brown fox jumps over the lazy dog

逗号输出为一个空格符

2,打印整数或计算结果

>>>print(100 + 200)
300
>>>print('100 + 200 =', 100 + 200)
100 + 200 = 300
字符串输入时需用''括起,非字符串时不需

输入

input()给变量赋值
1,查看变量内容

>>> name = input()
Alexia Lee
>>> name
'Alexia Lee'
>>> print(name)
Alexia Lee

2,添加提示信息
编辑运行程序hello.py

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

小结

输入是Input,输出是Output,因此,我们把输入输出统称为Input/Output,或者简写为IO。

相关文章

网友评论

      本文标题:廖雪峰 | 1.0 Python输入输出

      本文链接:https://www.haomeiwen.com/subject/dwgssrtx.html