作者cccx (ccc)
看板Python
标题Re: [问题] word count in files
时间Mon Feb 25 06:37:38 2008
※ 引述《azulazure (独在异乡为异客)》之铭言:
(deleted)
: I tried to use range function to do the work, but it didn't work.
: I wrote like this (following what I had above):
: for x in range(wordcount):
: if x in range(wordcount - 1) == False:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
此行有误
可改成: if
(x in range(wordcount - 1
) == False:
或是: if x
not in range(wordcount - 1):
: print x
: When I ran it, nothing happened. Can anyone tell me what's wrong?
: Or is there a better way to do it?
: My logic is that if the number is larger than the max number -1,
: it should be the largest number.
: Thanks in advance for any help!
何不直接印出max number (print wordcount) ?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.114.207.64
1F:推 azulazure:when I use "print max(wordcount)", it gives an error 02/25 06:46
2F:→ azulazure:says 'int' object is not iterable 02/25 06:47
3F:→ azulazure:and I still have problem how to print the file name 02/25 06:48
4F:→ azulazure:not just the number 02/25 06:48