笔记github地址:https://github.com/zhoushaodong666/python-study
一、第一个程序——HelloWorld
作为python入门的第一步,一定要写个神圣的HelloWorld
输出。
# 第一个程序 hello world
print("hello world")
二、变量
1. 变量的命名规范
- 变量名只可以包含 字母、数字、下划线。并且只有 字母、下划线可以开头
- 例如 name1 _name是正确的命名, 2name则是错误的命名
- 变量名不能包含空格 student name是错误 我们可以用下划线分隔 student_name
- 变量名不能使用python的一些关键字 就像 print 函数 这是python的保留字
2.变量的使用
# 我们用一个变量message来存 hello world!!
message = "hello world!!"
print(message)
# 变量变量 顾名思义变量是可以变的 即变量的值是可以改变的
message = "hello python!!"
print(message)
三、注释
注释可以让python编译器自动省略注释的代码。
1、单行注释
单行注释 通过 “#”
#print("我是当行注释")
2、多行注释
多行注释 通过三个单引号 ‘’'或者三个双引号 “”"
'''
我是三个单引号注释
'''
"""
我是三个双引号注释
"""