Open GoogleCodeExporter opened 9 years ago
下一版本(大概在周日下午发布)会同时支持UTF-8和ANSI编码��
�
感谢反馈。
Original comment by azly...@gmail.com
on 26 Oct 2011 at 4:34
Original comment by azly...@gmail.com
on 27 Oct 2011 at 4:56
能不能搞个随机ip,每个人都一样,恐怕不适合身处不同网络
运营商的苦逼
Original comment by huhang...@gmail.com
on 12 Nov 2011 at 1:39
iconv -f GBK -t utf-8 /etc/hosts -o /etc/hosts.out
mv /etc/hosts.out /etc/hosts
Original comment by Ludo.A...@gmail.com
on 2 Jan 2012 at 11:20
linux勉强能用的版本。
#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = "rikugun"
__modifier__ = "arnk"
import sys
import urllib
import os
from shutil import copyfile
HOSTS_URL = 'https://smarthosts.googlecode.com/svn/trunk/hosts'
LOCAL_HOSTS = '/etc/hosts'
LOCAL_HOSTS_BAK = '/etc/hosts.bak'
ICONV_CMD = "iconv -f GBK -t UTF-8 /etc/hosts -o /tmp/hosts"
MV_CMD = "mv /tmp/hosts /etc/hosts"
def main():
"""主函数.
"""
copyfile(LOCAL_HOSTS, LOCAL_HOSTS_BAK) #备份文件
with open(LOCAL_HOSTS, 'w') as hosts:
hosts.write(os.linesep) # 使用平台独立的换行符
for line in urllib.urlopen(HOSTS_URL):
hosts.write(line.strip() + os.linesep)
os.system(ICONV_CMD)
os.system(MV_CMD)
print "success!"
if __name__ == '__main__':
if len(sys.argv) > 1:
HOSTS_URL = sys.argv[1]
main()
Original comment by Ludo.A...@gmail.com
on 2 Jan 2012 at 11:29
Original issue reported on code.google.com by
Rojazz1...@gmail.com
on 26 Oct 2011 at 2:57