반응형

개인공부용이라 간단히올려요 :)

JSON 정의 (<출처 : 위키사전>)

인터넷에서 자료를 주고받을 때 그 자료를 표현하는 방법이다. 자료의 종류에 큰 제한은 없으며, 특히 컴퓨터 프로그램변수값을 표현하는 데 적합하다. 그 형식은 자바스크립트의 구문 형식을 따르지만, 프로그래밍 언어플랫폼에 독립적이므로 C, C++, C#, 자바, 자바스크립트, , 파이썬 등 많은 언어에서 이용할 수 있다.

Python에서의 JSON 예제

#data, data2, data3  비교형식으로 작성함

>>> import json                      
>>> data = {1:'a',2:'b'}
>>> data2 = json.dumps(data)
>>> data3 = json.loads(data2)
>>> type(data)
<type 'dict'>
>>> type(data2)
<type 'str'>
>>> type(data3)
<type 'dict'>
>>> print data
{1: 'a', 2: 'b'}
>>> print data2
{"1": "a", "2": "b"}
>>> print data3
{u'1': u'a', u'2': u'b'}

'Computer Languages > Python' 카테고리의 다른 글

Python에 Matplotlib 설치하는 방법  (0) 2022.06.21
Python에서 zlib 압축 푸는 방법  (2) 2016.01.25
Python에서 MySQL 연결하는 방법  (2) 2015.11.09
pydbg설치 참고 사이트  (0) 2014.11.29
urllib.urlencode  (0) 2013.01.22
반응형

======================================

개인 공부용도로 적었습니다. (나중에 까먹을까봐서 ㅋ_ㅋ)

======================================


<소스>

>>> import urllib
>>> data = {'x':'a'}
>>> data = urllib.urlencode(data)
>>> print data
x=a


data값 {'x':'a'}가 urllib.urlencode(data)공장을 지나서 x=a로 바뀌었다!!

반응형
string의 getline함수는 cin으로 입력받을때 공백도 같이 입력받을수 있다.

[예제]
// string_getline_sample.cpp
// compile with: /EHsc
// Illustrates how to use the getline function to read a
// line of text from the keyboard.
//
// Functions:
//
//    getline       Returns a string from the input stream.
//////////////////////////////////////////////////////////////////////

#pragma warning(disable:4786)
#include <string>
#include <iostream>

using namespace std ;

int main()
{
   string s1;
   cout << "Enter a sentence (use <space> as the delimiter): ";
   getline(cin,s1, ' ');
   cout << "You entered: " << s1 << endl;;
}

 

출처 : www.msdn.com

반응형
#include<iostream>
#include<string>
using namespace std;
int main()
{
string name;

cin >> name;
cout<< name.c_str();
}

//string은 객체이고 string의 맴버변수중에 char로 취급하는 c_str()이라는 것이 있다.

'Computer Languages > C | C++' 카테고리의 다른 글

[인공지능] A* 알고리즘을 이용한 8-puzzle 만들기  (10) 2015.04.04
string::getline  (0) 2010.11.19
[펌]private, proteted, public 의 차이  (3) 2010.10.12
[펌] new와 delete  (0) 2010.10.11
포인터 개념  (0) 2010.10.11

+ Recent posts