분류 전체보기354 python import MySQLdb as mdb import sys import json import MySQLdb import sys host = "localhost" db_id = "root" db_pw = "1q2w3e" db_name = "fitbit_db" db = MySQLdb.connect( host, db_id, db_pw, db_name ) cursor = db.cursor() #cursor.execute( "select version()" ) #data = cursor.fetchone() #cursor.execute( "show tables") #data = cursor.fetchall() #print data with open('001_sleep_start.txt') as f: data = f.. 2016. 2. 11. python import MySQLdb as mdb import sys import json import MySQLdb import sys host = "localhost" db_id = "root" db_pw = "1q2w3e" db_name = "fitbit_db" db = MySQLdb.connect( host, db_id, db_pw, db_name ) cursor = db.cursor() #cursor.execute( "select version()" ) #data = cursor.fetchone() #cursor.execute( "show tables") #data = cursor.fetchall() #print data with open('001_sleep_start.txt') as f: data = f.. 2016. 2. 11. python import MySQLdb as mdb import sys import json import MySQLdb import sys host = "localhost" db_id = "root" db_pw = "1q2w3e" db_name = "fitbit_db" db = MySQLdb.connect( host, db_id, db_pw, db_name ) cursor = db.cursor() #cursor.execute( "select version()" ) #data = cursor.fetchone() cursor.execute( "show tables") data = cursor.fetchall() print data print data db.close() with open('001_sleep_start.t.. 2016. 2. 11. python json parser python을 이용하여 json 파일을 파싱해서 값을 얻어오는 방법을 알아보도록 하자. json 샘플은 다음과 같다. config.json{ "snapshot" : {"repos" : "mingnewbie.tistory.com/repositories/snapshots","userid" : "mingnewbie","passwd" : "1234"},"release" : {"repos" : "mingnewbie.tistory.com/repositories/release","userid" : "mingnewbie","passwd" : "5678"},"component" : {"test":"mingnewbie.tistory.com"}} 위 config.json 파일을 열어서 파이썬으로 파씽을 해보자.아래 파이썬 .. 2016. 2. 2. 이전 1 ··· 31 32 33 34 35 36 37 ··· 89 다음