![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python那些年我学过的python
文章平均质量分 58
le_chateau
这个作者很懒,什么都没留下…
展开
-
20120904 python 不换行输出
一般的print 要换行输出 比如 s='test' for i in range(4): print s[i] >>> t e s t —————————————————————————————— s=str(range(4)) print"s="+s for i in range(len(s)): print s[i], print >>> s原创 2012-09-04 18:02:07 · 534 阅读 · 0 评论 -
Python list and tuple
tuple=('1','2','3') list=['1','2','3'] list[0]='a' #list可以直接做更改 print list tuple[0]='a' print tuple #这里会报错 因为这种赋值是不可以的 tuple不能更改 t1=tuple[0]+tuple[1]+tuple[2] #t1是一个字符串 因为tuple[i]都是字符串 t2=tuple[0],原创 2012-09-13 16:46:22 · 443 阅读 · 0 评论 -
Python sort
sort()是没有返回值的 只是做了一个操作 对序列进行更改 所以 如果你有一个list=[1,2,3,4,5] 你sort()了 那么 那就再真的sort()了 你还想使用原来的 最好复制一份 而且 copy=list是没用的 你要another_copy=[1,2,3,4,5] list=['4','5','w','a','g','14','ac'] another_list =[原创 2012-09-12 12:25:38 · 611 阅读 · 0 评论 -
Python list del remove
list=[13,'srt',453,'esr','13'] i=0 print list print 'del list[1]' del list[1] for i in range(len(list)): print 'list['+str(i)+']='+str(list[i])+str(type(list[i])) i+=1 i=0 print 'list.remove(13)' li原创 2012-09-09 19:42:38 · 2456 阅读 · 0 评论 -
python中的string
原文地址 :http://code.google.com/intl/zh-CN/edu/languages/google-python-class/strings.html 吃饭去~ 回来看 然后翻译! ———————————————————————————————————————————————————— 尼玛! 这一篇 真的没讲啥。浪费感情,酒足饭饱,拎着石榴,叼着棒棒糖,回来了 还要看翻译 2012-09-08 14:00:38 · 522 阅读 · 0 评论 -
ASCII,Unicode和UTF-8
转载自 http://www.ruanyifeng.com/blog/2007/10/ascii_unicode_and_utf-8.html 1. ASCII码 我们知道,在计算机内部,所有的信息最终都表示为一个二进制的字符串。每一个二进制位(bit)有0和1两种状态,因此八个二进制位就可以组合出256种状态,这被称为一个字节(byte)。也就是说,一个字节一共可以用来表转载 2012-09-08 17:12:28 · 501 阅读 · 0 评论 -
文件读
FILE=r'C:\Users\le_chateau\Desktop\test.txt' f=open(FILE,'r') out=f.read() f.close() text =out.decode('ascii') print text >>> If you were a teardrop;In my eye, For fear of losing you,I would ne原创 2012-09-08 11:48:30 · 398 阅读 · 0 评论 -
enumerate&&zip
enumerate可以取代以往的遍历 for i in enumerate('python'): print i >>> (0, 'p') (1, 'y') (2, 't') (3, 'h') (4, 'o') (5, 'n') ———————————————————————————————————————————————— print zip('today')原创 2012-09-06 19:01:44 · 1181 阅读 · 0 评论 -
python 统计字符串中数字,大小写,特殊字符
# -*- coding: utf-8 -*- print '统计字符串 数字 大小写的个数' import string s=raw_input() i=d=u=l=o=0 for i in range(len(s)): if s[i] in string.digits: d+=1 elif s[i] in string.uppercase: u+=1 elif s[i] in s原创 2012-09-06 11:28:32 · 8498 阅读 · 0 评论 -
Notepad++ 配置Python
1.打开Notepad++ 2. 按下F5 3. 将下列语句拷贝粘贴至输入框中: cmd /k python "$(FULL_CURRENT_PATH)" & PAUSE & EXIT 单击Save… 4. 在Shortcut窗口的设置:例如Ctrl+F5,单击OK保存此命令 5.关闭Run…窗口 6. 测试是否设置成功。 写下python语句 (此为python 2.x转载 2012-09-05 20:04:09 · 431 阅读 · 0 评论 -
pig latin
import string word=raw_input("Enter a word:") vowel=['a','e','i','o','u'] vowely=['a','e','i','o','u','y'] if (word[0] in vowel) : new_word=word+"hay" elif (word[0:2]=="qe"): new_word=word[2:]+word原创 2013-12-17 15:23:16 · 484 阅读 · 0 评论