python常用代码

用来复制粘贴用的

python2

# 网络访问
# -*- coding: utf-8 -*-
import sys
import urllib.request
import urllib.parse
...
# 读json,参考:https://www.jianshu.com/p/6fe5ce9001ec
#-*- coding: utf-8 -*-
import sys
import json


def trans(f_path):
  print("file:",f_path)
  with open(f_path) as f:
    print (f)
    txt = f.read();
    dic = json.loads(txt);
    value = dic['key']
    print value
    for pair in value:
      print(str(pair['lng'])+','+str(pair['lat'])+';'),

print ("__name__ = ",__name__)
if __name__ == '__main__':
  if len(sys.argv) != 2:
    print ("argv size not =1 ")
  else:
    trans(sys.argv[1])

你可能感兴趣的:(python,开发语言)