码迷,mamicode.com
首页 > 编程语言 > 详细

python笔记1

时间:2016-02-23 00:50:52      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:

1.字典不包含从左到右的顺序

2.If for 表达式:for x in xx:表达式  写为   表达式 for x in xx

3.元组,字符串 不可变性

(1)t.index()  t.count()

(2)T[0]=1 #change #error

(3)不能缩短、增长  无append

4.创建文件 f=open(‘data.txt’,’w’) #默认为 ‘r‘

           F.write(‘sherly’) #write strings of bytes to it returns number of bytes written

           F.close() #close to flush output buffers to disk

Open binary data ‘rb’

5.read() #字节  readline #

6.集合

X&Y #intersection

X|Y #union

X-Y #difference

7.分数

from fraction import Fraction

f=Fraction(2,3)

f+1

#Fracion(5,3)

8.检查处理对象的类型

if type(L) == list:

            print(‘yes‘)

python笔记1

标签:

原文地址:http://www.cnblogs.com/HackHer/p/5208568.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!