作者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
推 azulazure:when I use "print max(wordcount)", it gives an error 02/25 06:46
→ azulazure:says 'int' object is not iterable 02/25 06:47
→ azulazure:and I still have problem how to print the file name 02/25 06:48
→ azulazure:not just the number 02/25 06:48