易截截图软件、单文件、免安装、纯绿色、仅160KB

python的灵活

项目需要,刚刚接触python。
今天看书看到a>b==c ,a,b,c为integer
在C/C++/C#中,a>b为boolean,不可与integer比较相等
但python a>b==c等效于((a>b)&&(b==c))
在python中的写法是a>b and b==c


相关文档:

Python学习笔记 文件读写

Python中文件操作可以通过open函数,这的确很像C语言中的fopen。通过open函数获取一个file object,然后调用read(),write()等方法对文件进行读写操作。
1.open
使用open打开文件后一定要记得调用文件对象的close()方法。比如可以用try/finally语句来确保最后能关闭文件。
file_object = open('thefile.txt') ......

Python查找替换

>>> import string
>>> s='adbecf'
>>>
tt=string.maketrans("abc","ABC")
>>> s.translate(tt,"")
'AdBeCf'
>>>
s.translate(tt,"")
后面的那个空字符创就是你要删除的字符,比如要删除换行就是s.translate(tt,"\n&q ......

python下的web开发框架 Django,url配置

url配置
我们在polls这个app下创建一个
helloworld.py
from django.http import HttpResponse
def index(request):
    return HttpResponse("Hello, Django.")
修改 urls.py
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
# from django.contrib ......

Python日期和字符串的互转

用的分别是time和datetime函数
'''
Created on 2009-9-2
@author: jiangqh
'''
import time,datetime
# date to str
print time.strftime("%Y-%m-%d %X", time.localtime())
#str to date
t = time.strptime("2009 - 08 - 08", "%Y - %m - %d")
y,m,d = t[0:3]
print datetime.datetime(y,m,d)

输出当前时间 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号