试试这个 [英] Try this
问题描述
我不确定我理解你的第一个问题,但要查看 glob"
模块。听起来可能会有所帮助。
以下是如何获取文件夹和文件名
import os
list = os.walk(" C:\ python24 \Tools")
列表中的文件:
folderlist = os.path.split (文件[0])
打印" ****************文件夹***************" ;
打印文件夹列表[1]
print" ========================= ============"
打印
打印" ****************文件*****************"
打印文件[2]
打印" ====== ==============================="
I''m not sure I understand your first question but checkout the " glob "
module. Sounds like it may help.
Here is how you could get the folders and filenames
import os
list = os.walk("C:\python24\Tools")
for file in list:
folderlist = os.path.split(file[0])
print "****************Folder***************"
print folderlist[1]
print "====================================="
print
print "****************Files*****************"
print file[2]
print "====================================="
推荐答案
RunLevelZero写道:
RunLevelZero wrote:
我不确定我是否理解你的第一个问题,但要查看 glob"
模块。听起来可能有所帮助。
I''m not sure I understand your first question but checkout the " glob "
module. Sounds like it may help.
你在和谁说话?如果你从
原始邮件中引用文本,留下一些原始主题,并回复
原始邮件而不是发布新邮件,这将有所帮助。 />
-
Michael Hoffman
Who are you talking to? It would help if you quoted text from the
original message, left some of the original subject, and replied to the
original message instead of making a new post.
--
Michael Hoffman
确实..我点击了回复,但我想我没有注意。我的
坏。
Indeed.. I did click reply but I guess I wasn''t paying attention. My
bad.
在2005年7月24日最黑暗的时刻12:10:47 -0700,
RunLevelZero< Ai ******* @ gmail.com>尖叫:
In the darkest hour on 24 Jul 2005 12:10:47 -0700,
RunLevelZero <Ai*******@gmail.com> screamed:
list = os.walk(" C:\ python24 \Tools")
list = os.walk("C:\python24\Tools")
r" C:\ python24 \工具"
Artur
-
[Artur M. Piwko:Pipen:AMP29- RIPE:RLU:100918:来自==陷阱! :SIG:230B]
[01:45:21用户最多10684天,13:40,1位用户,平均负载:0.06,0.06,0.06]
未找到备份:A)bort,R)etry,M)是否有心力衰竭?
r"C:\python24\Tools"
Artur
--
[ Artur M. Piwko : Pipen : AMP29-RIPE : RLU:100918 : From == Trap! : SIG:230B ]
[ 01:45:21 user up 10684 days, 13:40, 1 user, load average: 0.06, 0.06, 0.06 ]
Backup not found: A)bort, R)etry, M)assive heart failure?
这篇关于试试这个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!