compatible with Python 2.* (#42)

This commit is contained in:
Ruqi
2017-08-13 09:04:36 +08:00
committed by 胡中元
parent 35b6c944f1
commit bdff2480bd

View File

@@ -69,7 +69,14 @@ for rule_url in rules_url:
domains.sort()
file_ad = open('resultant/ad.list', 'w', encoding='utf-8')
file_ad = sys.stdout
try:
if sys.version_info.major == 3:
file_ad = open('resultant/ad.list', 'w', encoding='utf-8')
else:
file_ad = open('resultant/ad.list', 'w')
except:
pass
file_ad.write('# adblock rules refresh time: ' + time.strftime("%Y-%m-%d %H:%M:%S") + '\n')