Python的输出
输出比较简单,直接向屏幕上输出指定文字,例如‘hello world’,使用如下代码即可
>>> print(
'hello world')
当然也可以输出多个字符串使用‘,’逗号隔开,就可以连成一串输出。
>>>
print(
'hello world',
'hello python')
hello world hello
python
可以看到python输出过程中把逗号替换成了空格。 同理可以输出整数、浮点数等等
Python的输入
假如我们想要给某个变量进行输入,该如何进行呢? 通过input()可以让用户输入字符串并存储在一个变量中。例如:
>>> print(
'input:')
>>> string = input()
>>> print(string)
input:
hi python
hi python
另外要注意的是python的注释使用#开头,并且严格执行缩进!按照常用的缩进格式一般都是4个空格。python和C++等一些语言一样是大小写敏感的!