0
点赞
收藏
分享

微信扫一扫

python 《一》基础


python 基础

#python分为python2和python3具体区别没多大可以网上看下

#python定义很简单

#下边是定义例子

s1 = "wangwu"
i1 = 123
f1 = 12.3

#基本操作函数

len(s1) #长度
dir(str) #查询模块内方法
help(str) #帮助文档
s1 = input('输入内容:')#输入方法
print s1 #打印
import urllib 引入模块

python 中的模块就是python的文件名xxx.py

#字符输出格式

s1 = u'wangwu' 
print 'hello %d' %123

#list序列

ls1 = [1,2,3,4,5,6]
ls1[2] #分片查询
ls1.append(233) #尾部添加
ls1.insert(2,123) #在2位置添加123
ls1.pop() #删除尾部一个
ls1.pop(3) #三餐3位置上的内容

元组

t1=(1,2,3)    #元组不可改变

字典

d={'s':22,'b':'cc'}
d['b']

#列表生成

g =(i for i in range(1,10))
for s in [i for i in range(1,10)]:print s#输出序列

#定义类

class index:
#定义方法
def GET(self, name):
print 'index get value '+ name
web.header('Content-Type', 'text/html;charset=UTF-8')
return 'hello' + name + u'欢迎你哟!'

 
  
#运行

if __name__ == "__main__":
print ’hello'

 

举报

相关推荐

python基础一

python<一>基础

python基础(一)

Python(一、基础)

python基础补充(一)

python基础学习一

0 条评论