-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_country_flag.py
More file actions
73 lines (57 loc) · 1.72 KB
/
Copy pathcheck_country_flag.py
File metadata and controls
73 lines (57 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/12/4 15:20
# @Author : GuoChang
# @Site : https://github.com/xiphodon
# @File : check_country_flag.py
# @Software: PyCharm
# 检查国家&国旗
import pymssql
import settings
import os
def get_server_country_set():
"""
获取服务端国家集合
:return:
"""
conn = pymssql.connect(host=settings.host, user=settings.user, password=settings.password,
database=settings.database, charset=settings.charset)
cur = conn.cursor()
if not cur:
raise (NameError, "数据库连接失败")
cur.execute('select Name from Country')
country_name_list = cur.fetchall()
country_name_set = set([x[0].lower() for x in country_name_list])
conn.close()
return country_name_set
def get_country_flag_set():
"""
获取本地国旗集合
:return:
"""
flag_set = set()
for item_flag in os.listdir(r'C:\Users\topeasecpb\Desktop\new-country\country'):
# print(item_flag)
if item_flag.endswith('.png'):
flag_set.add(item_flag.lower().replace('.png', ''))
return flag_set
def get_no_flag_country_set():
"""
获取没有国旗的国家集合
:return:
"""
flag_set = get_country_flag_set()
# print(flag_set)
country_set = get_server_country_set()
# print(country_set)
no_flag_country_set = country_set - flag_set
no_country_flag_set = flag_set - country_set
print(flag_set)
print(len(flag_set))
print(len(country_set))
print(no_country_flag_set)
print(len(no_country_flag_set))
print(no_flag_country_set)
print(len(no_flag_country_set))
if __name__ == '__main__':
get_no_flag_country_set()