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

python读取目录下文件并生成日志

很长的一段代码,但很清楚。哈哈。
import os
from time import strftime
stamp=strftime("%Y-%m-%d %H:%M:%S")
logfile = 'F:\\test\\m-php-framework\\tmp\logs\\error_report.log'
path = 'F:\\test\\'
files = os.listdir(path)
bytes = 0
numfiles = 0
for f in files:
if f.startswith('t'):
info = os.stat(path + f)
numfiles +=1
bytes+=info[6]
if numfiles > 1:
title = 'tiles'
else:
title = 'file'
string = stamp + " -- " + str(numfiles) + " session" +title+","+ str(bytes)+" bytes\n"
file = open(logfile,"a")
file.writelines(string)
file.close()


相关文档:

python 笔记 for loop and extend, append

list.append(item)
list.extend(sequence)
http://docs.python.org/tutorial/datastructures.html
http://docs.python.org/library/functions.html 这几天看一下
python howto
恩。python documentation 确实很好很强大啊!
list.append(x)Add an item to the end of the list; equivalent to a[len(a):]&n ......

手动制作python的exe可执行程序


1. 手动制作python的exe可执行程序
                                      转载---------------
Python没有内建一个编 ......

使用Python读SEGY道头

自己遇到的一个问题, WestGeco的3D地震数据, 提取导航数据:
#!/bin/env python
import sys
import struct
try:
        f=open(sys.argv[1],'rb')
except (IOError,Exception):
    print '''usage:
        scriptname segyfilename
'''
&nbs ......

用 Python 3 写的命令行百度词典

今天是第二天自己看关于Python了,看见一个Python2写的百度词典,我也用Python 3 写了一个。真的很小巧,呵呵,很好的语言。
不知道怎么上传代码格式的,就上传文本了:
# -*- coding: utf8 -*-
import urllib.parse
import urllib.request
def search(word):
    #word = input("输入你要查询的 ......

python模块之codecs

python对多国语言的处理是支持的很好的,它可以处理现在任意编码的字符,这里深入的研究一下python对多种不同语言的处理。
    有一点需要清楚的是,当python要做编码转换的时候,会借助于内部的编码,转换过程是这样的:
        原有编码 -> 内部编码 ->
目 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号