Open source software supply chain lighting plan, waiting for you>>>
#encoding=utf-8
import os
result = {}
if os.path.exists("test.txt"):
day_file = open("test.txt").read()
day_file_list = day_file.split(" ")
for i in day_file_list:
# print "i: s" + str(i) + "e"
if i == "#" or " ":
day_file_list.remove(i)
#continue
if i not in result:
result[i] = 1
else:
result[i] = result[i] + 1
# print "result i: " + str(result[i])
result = sorted(result.items(), key = lambda item: item[1], reverse=True)
for k in result.keys():
print result[k]
Solution:
for i in result:
print i
Similar Posts:
- AttributeError: ‘dict‘ object has no attribute ‘iteritems‘
- Pytest @pytest.mark.parametrize Example
- Python scrapy/ ERROR: Spider must return request, item, or None, got ‘Tag ‘insettlement program
- [leetcode] 140. Word break II word split II
- Python TypeError: unbound method a() must be called with A instance as first argument (go…
- [Solved] Python TypeError: sequence item 0: expected str instance, int found
- Problems encountered in using Maven – lambda expressions are not supported at language level’5 ‘
- Fast locating nonetype ‘object is not Iterable in Python
- ValueError: day is out of range for month [How to Solve]
- ValueError: day is out of range for month [How to Solve]