
彭亮之Python语言编程基础
忧郁一休
算法初学者
展开
-
第23节--python创建网页
1. 下载并安装python 2.72. 安装 lpthw.web库 windows 命令行下执行: C:\Python27\Scripts\easy_install lpthw.web3. 创建目录 D:\eclipse\mars\project\TeachingPython\gotoweb\bin4. 在该目录下创建 app.py,输入以下代码:# -*- coding: utf-8 -*-原创 2016-10-31 14:40:16 · 2219 阅读 · 0 评论 -
第3节--PyDev配置
Windows 命令行中如何运行Python (配置环境变量) win+r——cmd——直接键入python,显示python不是内部或者外部命令。。。 因此我们需要首先将python的路径添加到系统的环境变量中,过程如下(以win10为例):右键此电脑——属性——高级系统设置——环境变量——系统变量——找到Path——双击打开——点击新建——输入你安装的python的路径(我这里是C:\Pyt原创 2016-10-21 16:09:03 · 935 阅读 · 0 评论 -
第2节--Python环境配置
1、下载pythonpython官方下载地址版本选择: 进入官网后,点击downloads,目前(2016年10月)最新版本是3.5.2,课程发布时(2014年10月)最新版本是3.4.2注意:python2和python3的区别下载流程:一、打开python3.5.2的下载地址二、找到下图,点击download三、拖到页面底部,找到下图注意:我的操作系统为win10,64位,所以我选的是方框的那原创 2016-10-21 15:04:29 · 868 阅读 · 0 评论 -
第1节--python课程介绍
本课程是麦子学院彭亮老师讲授的《python语言编程基础》 课程视频地址 共23小节,以下为我的学习笔记1、python语言介绍面向对象,解释型计算机程序设计语言1989年Guido van Rossum发明,1991年公开版本发行广泛应用于科学计算,众多开源科学计算软件包提供Python接口 (OpenCV)用途: 网页开发可视化(GUI)界面开发网络系统编程数原创 2016-10-21 14:39:51 · 3745 阅读 · 1 评论 -
第4节--Built-in package和External package
新建Python项目 file——new——PyDev project——输入project name(TeachingPython)——修改grammar version为3.0-3.5——修改interpreter为python34——next——finish 新建Python的Module 在TeachingPython右键——new——Python Module——package不管原创 2016-10-21 19:44:59 · 1039 阅读 · 0 评论 -
第5节--python数据类型--numeric
python数据类型总体:numerics, sequences, mappings, classes, instances, exceptionsNumeric Types: int (包含boolean), float, complexint: unlimited length; float: 实现用double in C, 可用 sys.float_info查看; complex: re原创 2016-10-23 21:38:25 · 3178 阅读 · 0 评论 -
第8节--python数据结构--tuple
元组(tuple)创建#create tuplenumber_tuple = (1,2,3)string_tuple = ("hello","nihao","doubi")mixed_tuple = ("world",100,"weixin")print(number_tuple[0])print(string_tuple[1])print(mixed_tuple[2])访问#update原创 2016-10-24 22:23:50 · 327 阅读 · 0 评论 -
第10节--python数据结构--dictionary
python数据结构:dictionarydictionary结构介绍dictionary基本操作dictionary内置函数dictionary内置方法原创 2016-10-25 11:47:10 · 478 阅读 · 0 评论 -
第9节--列表list与元组tuple的对比
创建只有一个元素的tuple,需要用逗号结尾消除歧义a_tuple = (2,)tuple中的listmixed_tuple = (1, 2, ['a', 'b'])print("mixed_tuple: " + str(mixed_tuple))mixed_tuple[2][0] = 'c'mixed_tuple[2][1] = 'd'print("mixed_tuple: " + str(mi原创 2016-10-24 22:25:07 · 317 阅读 · 0 评论 -
第7节--python数据结构--list
1. print中的编码: 解决中文编码问题:# -*- coding: utf-8 -*-2. print中的换行 print("What's your name? \nTom")3. list创建#创建listnumber_list = [1,3,5,7,9]print("number_list: "+str(number_list))string_list = ["ja原创 2016-10-24 19:25:43 · 440 阅读 · 0 评论 -
第11节--function(上)
knowledge points函数:程序中可重复使用的程序段给一段程程序起一个名字,用这个名字来执行一段程序,反复使用 (调用函数)用关键字 ‘def’ 来定义,identifier(参数)identifier 参数listreturn statement局部变量 vs 全局变量code# -*- coding: utf-8 -*-#no parameter no return valuedef原创 2016-10-25 13:33:04 · 353 阅读 · 0 评论 -
第12节--function(下)
knowledge points:默认参数关键字参数VarArgs参数Code:# -*- coding: utf-8 -*-# default parameterdef repeated_str(str,times = 1): repeated_strs = str * times return repeated_strs# repeated_strings = repeated原创 2016-10-25 13:59:00 · 322 阅读 · 0 评论 -
第13节--条件语句和循环语句
1. if 语句if condition: do something elif other_condition: do something else: do somethingcode# if statement examplenumber = 59guess = int(input("Enter an integer: "))# print("guess原创 2016-10-25 21:39:12 · 429 阅读 · 0 评论 -
第22节--python猜数字游戏(图形界面)
1. GUI from tkinter2. 逻辑层from tkinter import *import tkinter.simpledialog as dlimport tkinter.messagebox as mbroot = Tk()w = Label(root,text = "Guess Number")w.pack()mb.showinfo("Welcome","Welcome T原创 2016-10-31 14:05:41 · 3529 阅读 · 0 评论 -
第21节--python的GUI编程
1. GUI: Graphical User Interface2. tkinter: GUI library for Python3. GUI Examplefrom tkinter import *import tkinter.simpledialog as dlimport tkinter.messagebox as mbroot = Tk()w = Label(root,text = "原创 2016-10-31 13:32:49 · 408 阅读 · 0 评论 -
第20节--python面向对象编程与装饰器
1. 面向对象编程Python支持面向对象编程类(class):现实世界中一些事物的封装 (如:学生) 类:属性 (如:名字,成绩)类对象 实例对象引用:通过引用对类的属性和方法进行操作 实例化:创建一个类的具体实例对象 (如:学生张三)class Student: def __init__(self,name,grade): self.name = name原创 2016-10-31 11:53:29 · 545 阅读 · 0 评论 -
第19节--python常见错误与异常处理
语法错误# while True print("hello world")# print(8/0)# print(hello * 4)# num = 6# print("hello" + num)异常处理# while True:# try:# x = int(input("Please enter a numer: "))# break#原创 2016-10-31 11:36:56 · 512 阅读 · 0 评论 -
第18节--python文件读写
写出文件some_sentences = '''\I love pythonbecause python is funand python is ease to use'''f = open('somesentences.txt','w')f.write(some_sentences)f.close()读入文件f = open('somesentences.txt')while Tru原创 2016-10-31 11:01:27 · 318 阅读 · 0 评论 -
第17节--python的输入输出(IO)
python界面的输入与输出语句:接受用户的输入: input()输入格式:str(), formatstr_1 = input("Enter a string: ")str_2 = input("Enter another string: ")print("str_1 is "+str_1+",str_2 is "+str_2)print("str_1 is {} and str_2 is {原创 2016-10-31 10:21:56 · 373 阅读 · 0 评论 -
第16节--break&continue&pass
codecontinue:直接忽略下面的内容,返回开始处,进行下一轮的循环 pass:执行完下面的内容,再返回开始处,进行下一轮的循环a_list = [0,1,2]print("using continue")for i in a_list: if not i: continue print(i)print("using pass")for i in a_li原创 2016-10-25 22:24:58 · 390 阅读 · 0 评论 -
第15节--While语句(下)
codenumber = 59guess_flag = Falsechance = 3for i in range(1,chance+1): print("chance: "+str(i)) guess = int(input("enter an integer: ")) if guess == number: guess_flag = True原创 2016-10-25 22:11:58 · 307 阅读 · 0 评论 -
第14节--while语句(上)
codenumber = 59guess_flag = Falsewhile guess_flag == False: guess = int(input("enter an integer: ")) if guess == number: guess_flag = True elif guess <number: print("the nu原创 2016-10-25 21:56:47 · 425 阅读 · 0 评论 -
第6节--python数据类型--string
1. 字符串:编码:# -- coding: utf-8 -- 单引号=双引号 三引号(换行) 不可变(immutable)Format字符串age = 3name = "Tom"print("{0} was {1} years old".format(name, age))联合:+: print(name + " was " + str(age) + " years原创 2016-10-23 22:30:27 · 424 阅读 · 0 评论