2005年06月22日 星期三 08:08
看来欧洲的专利法案使得很多开源项目都受到了影响,xine mplayer的主页上都有类似的有关于此的声明.呜呼 在05-6-21,Wang Kebo <mep_ at 163.com> 写道: > > 我突然明白了,中文应该使用机器翻译的。。。:) > 居然把china翻译成瓷 > __ > Best Regards, > > Kebo Wang > > >-----Original Message----- > >From: python-chinese-bounces at lists.python.cn > >[mailto:python-chinese-bounces at lists.python.cn] On Behalf Of Dirk > >Sent: Tuesday, June 21, 2005 7:56 PM > >To: python-chinese at lists.python.cn > >Subject: [python-chinese] Hello, 重要问题 > > > >I'm from europe and I'm desperately looking for a Sourceforge > >like CVS server in china because of software patents. > > > >Thanks for any suggestions, > >Dirk > > > >我是从欧洲并且我绝望地寻找一Sourceforge 象CVS 服务 器在瓷由于软件专利。 > >感谢任何建议, Dirk > > > >_______________________________________________ > >python-chinese list > >python-chinese at lists.python.cn > >http://python.cn/mailman/listinfo/python-chinese > > > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > -- 茫茫人海,你是我的最爱 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20050622/61faf1f7/attachment.html
2005年06月22日 星期三 09:26
python-chinese,您好!
想要在Python中实现获取系统文件列表。就像 UNIX 下的 ls 或Dos 下的 dir 命令。
如 dir *.cfg
ls a* b*.cfg
要求运行通配符*、?,最好可以输入多个字符串。
我找了一下Python的库函数,没有发现有类似的实现。os.listdir 只能输入一个路径名
>>> os.listdir('*')
Traceback (most recent call last):
File "", line 1, in ?
OSError: [Errno 2] No such file or directory: '*'
我自己采用了类似下面的代码
def listfiles(paths, recursive_time = 1):
for one in paths:
if os.path.isfile(one):
result.append(one)
elif os.path.isdir(one):
if (recursive_time <= 0):
result.append(one)
else:
result += listfiles(fullnames, recursive_time - 1)
。。。。
像这样依次进行判断来实现的,不过总觉得这样比较难看,并且对通配符比较难处理。
各位有没有好一点的思路?
致
礼!
范洪滔
2005年06月22日 星期三 09:33
import os, fnmatch
def all_files(root, patterns='*', single_level=False, yield_folders=False):
# Expand patterns from semicolon-separated string to list
patterns = patterns.split(';')
for path, subdirs, files in os.walk(root):
if yield_folders:
files.extend(subdirs)
files.sort( )
for name in files:
for pattern in patterns:
if fnmatch.fnmatch(name, pattern):
yield os.path.join(path, name)
break
if single_level:
break
thefiles = list(all_files('C:\\PS', '*.jpg'))
忘记哪本书上的例子了
On 6/22/05, 范洪滔 <fanhongtao at huawei.com> wrote:
>
> python-chinese,您好!
>
> 想要在Python中实现获取系统文件列表。就像 UNIX 下的 ls 或Dos 下的 dir 命令。
> 如 dir *.cfg
> ls a* b*.cfg
> 要求运行通配符*、?,最好可以输入多个字符串。
>
> 我找了一下Python的库函数,没有发现有类似的实现。os.listdir 只能输入一个路径名
> >>> os.listdir('*')
> Traceback (most recent call last):
> File "", line 1, in ?
> OSError: [Errno 2] No such file or directory: '*'
>
> 我自己采用了类似下面的代码
>
> def listfiles(paths, recursive_time = 1):
> for one in paths:
> if os.path.isfile(one):
> result.append(one)
> elif os.path.isdir(one):
> if (recursive_time <= 0):
> result.append(one)
> else:
> result += listfiles(fullnames, recursive_time - 1)
> 。。。。
>
> 像这样依次进行判断来实现的,不过总觉得这样比较难看,并且对通配符比较难处理。
> 各位有没有好一点的思路?
>
>
>
> 致
> 礼!
>
> 范洪滔
>
>
>
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
>
--
欢迎访问我的Blog:
http://spaces.msn.com/members/meaglith/
http://blog.360.yahoo.com/genednaparadox
----------------------------------------
.--.
|o_o |
|:_/ |
// \ \
(| | )
/'\_ _/`\
\___)=(___/
-------------------------------------------------
沧海笑 滔滔两岸潮 浮沉随浪记今朝
苍天笑 纷纷世上潮 谁负谁胜天知晓
江山笑 烟两遥 涛浪淘尽红尘俗也知多少
竟惹寂寥 一襟晚照
苍生笑 不再寂寥 豪情仍在痴痴笑笑
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20050622/41c3c880/attachment.htm
2005年06月22日 星期三 09:37
def finder(self):
"""文件查找器
060706 基本设计,glob 匹配文件,walk 进行遍历;
返回一个全路径修饰的文件数组
"""
if("-R"==self.param[0]):
"""进行递归匹配,意外为没有 target 或是 target 不是目录
"""
if os.path.isdir(self.param[1]):
print "使用 -R 选项时,第二个参数应该是文件名!"
elif "-" in self.param[2]:
print "使用 -R 选项时,第三个参数应该是文件匹配模式!"
else:
if os.path.exists(self.param[2]):
os.path.walk(self.param[2],self.ffilter,self.param[1])
return self.ffli
else:
print self.param[2]+" 不是有效的目录"
print "使用 -R 选项时,第四个参数应该是有效的目录引用!"
else:
"""进行单独文件处理
"""
if os.path.isdir(self.param[0]) or ("-" in self.param[0]):
if("-h" in self.param or "-help" in self.param):
return "help"
else:
print "不使用 -R 选项时,第一个参数应该是文件名!"
else:
return
reduce(operator.add,map(glob.glob,self.param[0].split(",")))
Python 本身有专门的 文件搜索支持的!
在 05-6-22,范洪滔<fanhongtao at huawei.com> 写道:
> python-chinese,您好!
>
> 想要在Python中实现获取系统文件列表。就像 UNIX 下的 ls 或Dos 下的 dir 命令。
> 如 dir *.cfg
> ls a* b*.cfg
> 要求运行通配符*、?,最好可以输入多个字符串。
>
> 我找了一下Python的库函数,没有发现有类似的实现。os.listdir 只能输入一个路径名
> >>> os.listdir('*')
> Traceback (most recent call last):
> File "", line 1, in ?
> OSError: [Errno 2] No such file or directory: '*'
>
> 我自己采用了类似下面的代码
>
> def listfiles(paths, recursive_time = 1):
> for one in paths:
> if os.path.isfile(one):
> result.append(one)
> elif os.path.isdir(one):
> if (recursive_time <= 0):
> result.append(one)
> else:
> result += listfiles(fullnames, recursive_time - 1)
> 。。。。
>
> 像这样依次进行判断来实现的,不过总觉得这样比较难看,并且对通配符比较难处理。
> 各位有没有好一点的思路?
>
> 致
> 礼!
>
> 范洪滔
>
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
>
--
[Time is unimportant, only life important!]
2005年06月22日 星期三 10:26
使用glob模块 在 05-6-22,范洪滔<fanhongtao at huawei.com> 写道: > python-chinese,您好! > > 想要在Python中实现获取系统文件列表。就像 UNIX 下的 ls 或Dos 下的 dir 命令。 > 如 dir *.cfg > ls a* b*.cfg > 要求运行通配符*、?,最好可以输入多个字符串。 > > 我找了一下Python的库函数,没有发现有类似的实现。os.listdir 只能输入一个路径名 > >>> os.listdir('*') > Traceback (most recent call last): > File "", line 1, in ? > OSError: [Errno 2] No such file or directory: '*' > > 我自己采用了类似下面的代码 > > def listfiles(paths, recursive_time = 1): > for one in paths: > if os.path.isfile(one): > result.append(one) > elif os.path.isdir(one): > if (recursive_time <= 0): > result.append(one) > else: > result += listfiles(fullnames, recursive_time - 1) > 。。。。 > > 像这样依次进行判断来实现的,不过总觉得这样比较难看,并且对通配符比较难处理。 > 各位有没有好一点的思路? > > 致 > 礼! > > 范洪滔 > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > -- I like python! My Donews Blog: http://www.donews.net/limodou New Google Maillist: http://groups-beta.google.com/group/python-cn
2005年06月22日 星期三 11:50
似乎有个学习python的网站,提供大量python练习题,就好像游戏过关一样,答案正确 才能继续,那个网站的网址忘掉了,各位若知晓,望告知,不胜感谢!
Zeuux © 2025
京ICP备05028076号