Python入门(一)
2016-01-17 16:52
447 查看
安装
安装python
环境变量设置为 C:\Python34 即可(或27)在cmd中输入 python 测试是否配置正确环境变量
lxml(flask等)
easy_install lxml (不推荐)pip install lxml
手动安装 下载lxml库( http://www.lfd.uci.edu/~gohlke/pythonlibs/ )— 后缀名改为zip,解压— 将lxml文件夹放入C:\Python27\Lib中— 在.py 中import lxml 看报不报错
Python入门(一)
Python语言基本语法
判断
s = 90 if s >= 80: # 判断 print("很好") else: print("vjls") # elif
循环
for i in range(0, 10): # 循环 print("Item {0} {1}".format(i, "hello")) # 字符拼接
定义函数
def sayhello(): # 定义函数 print("hello") sayhello()
类及继承
class Hello: def __init__(self, name): self._name = name def sayhello(self): print("hello {0}".format(self._name)) h = Hello("dr") h.sayhello()
# coding=utf-8 class Fa: def __init__(self, name): self._name = name def sayhello(self): print("hello {0}".format(self._name)) class Son(Fa): # 在括号里写父类 def __init__(self, name): Fa.__init__(self, name) def sayhi(self): print("hi {0}".format(self._name)) h = Fa("dr") h.sayhello() h1 = Son("wang") h1.sayhi()
引入 Python文件
import mylib # 引入文件 h = mylib.Hello()
from mylib import Hello # 引入文件的一部分 h = Hello()
Python语言Web开发框架web2py
相关文章推荐
- Python变量与运算符
- pythonchallenge(29-33)
- pythonchallenge(25-28)
- pythonchallenge(21-24)
- 配置python环境变量(转)
- 使用python,scrapy写(定制)爬虫的经验,资料,杂。
- python小白-day3 collections系列
- Python学习1(环境搭建、文件格式与简单编程)
- python使用yield来减少内存开销
- python—面向对象编程
- 使用Python Pandas处理亿级数据
- 安装pip ---python windows
- 线性回归及其Python实现(最大似然法)
- Python+django实现文件下载
- VS2010中嵌入python
- Python+django实现文件上传
- python多线程的用法之一
- 【Python学习笔记】-利用MySQLdb操作mysql数据库
- 我的Python成长之路---GitHub使用克隆GitHub(SSH key配置)
- 我的Python成长之路---GitHub使用之注册GitHub并安装Git客户端