python_day1_程序交互

时间:2023-03-10 01:36:44
python_day1_程序交互

程序交互

在编写程序过程中总会有程序与用户交互的场景出现,这里面提到python会使用一个方法:input

用法:

例如:请用户输入一个账号

input"Please input your username:")

这里面只是单纯的输入,但没有在存储,所以需要对此设置一个存储的变量

username = input"Please input your username:")

python_day1_程序交互

这个时候我们打印username

python_day1_程序交互

注释

为了增加代码的可读性,需要对代码进行注释

代码注释分单行和多行注释,单行注释用# ,多行注释用""" ... """

单行注释:

#打印hello world

print("hello world)

多行注释:

"""
msg = {
'egon':'123',
'alex':'3714' }
"""