Python Cheet Sheet =============================== ******************************************************************************** ## Send and Recive json ******************************************************************************** import json import requests data = { "radioType": "gsm", "cellTowers": [ { "cellId": 20102, "locationAreaCode": 5241, "mobileCountryCode": 432, "mobileNetworkCode": 11 }, { "cellId": 10102, "locationAreaCode": 5241, "mobileCountryCode": 432, "mobileNetworkCode": 11 }, { "cellId": 20372, "locationAreaCode": 5241, "mobileCountryCode": 432, "mobileNetworkCode": 11 }, { "cellId": 30243, "locationAreaCode": 5241, "mobileCountryCode": 432, "mobileNetworkCode": 11 }, { "cellId": 30102, "locationAreaCode": 5241, "mobileCountryCode": 432, "mobileNetworkCode": 11 }, { "cellId": 20050, "locationAreaCode": 5241, "mobileCountryCode": 432, "mobileNetworkCode": 11 } ] } data_json = json.dumps(data) r = requests.get('https://location.services.mozilla.com/v1/geolocate?key=test', data = data_json) print r.content ******************************************************************************** ## Navigate whole directory and make index for files ******************************************************************************** import sys,os f1=open('./index.html', 'w+') print >> f1,"" for path, subdirs, files in os.walk("."): tmp = "" for name in files: file = os.path.join(path, name) if file.startswith('./.git') == False and file.startswith('./index') == False : if tmp != path : tmp = path print >>f1, "

"+path+"

" print >>f1, ""+name+"
" _BY: Farid Ahmadian_ _TAG: python, gis_ _DATE: 2014-01-27 19:36:53_