python基础语法
来源:互联网 发布:单片机设计实例 编辑:程序博客网 时间:2024/05/19 02:30
python基础语法小汇总
test.py
# coding utf-8#1. 打印常量print("1. 打印常量") print("hello python") #2. 定义变量print("2. 定义变量") a = 10b = 20c=a+bprint("c = {0}".format(c))#3. 条件判断print("3. 条件判断") score = 65if score>=80 : print("good")elif score>=60 : print("及格") print ("马马虎虎")elif score>=40 : print("not good")else : print("bad") #4. 循环print("4. 条件判断") for i in range(0,5): print(i) #5. 定义函数print("5. 定义函数") def hello(): print("hello wlh")hello()#6.面向对象print("6. 面向对象 class") class test : def hi() : print("print from test hi()") hello() test.hi()#7.引入python文件print("7.引入python文件") import otherclass1 = other.otherclass()class1.display()
other.py#另一个文件class otherclass: def display(self): print("open the other file")#otherclass.display()
输出结果:1. 打印常量
hello python
2. 定义变量
c = 30
3. 条件判断
及格
马马虎虎
4. 条件判断
0
1
2
3
4
5. 定义函数
hello wlh
6. 面向对象 class
print from test hi()
hello wlh
7.引入python文件
open the other file
阅读全文
0 0
- 【python】python语法基础
- Python基础语法学习
- Python 基础语法知识
- Python基础语法
- python 基础语法
- Python基础语法
- python语法 -- 基础篇
- Python 语法基础
- Python基础语法
- Python 基础语法(一)
- Python 基础语法(二)
- Python基础语法
- Python基础语法
- Python基础语法笔记
- Python 基础语法(一)
- Python 基础语法
- Python基础语法学习
- Python 基础语法(1)
- 1060. Are They Equal (25)
- recyclerView和retrofit的简单使用
- Ueditor编辑器图片上传自定义配置
- javascript--BOM概念
- EXCLUDE/INCLUDE
- python基础语法
- This page contains the following errors: error on line 1 at column 1: Extra content at the end of t
- java的HashMap类提供的方法
- ffmpeg音频处理——pcm格式与resample(重采样)
- CSS初始化样式
- blend画图技巧
- 并发库之同步屏障
- RecyclerView
- 用js快速动态生成bootstrap table表格数据