저는 Python에 익숙하지 않으며이 내용을 읽는 것이 매우 쉽지만 어떤 이유로 오류를 디버그 할 수 없습니다. 내가 JSON 문자열을 반환하는 subprocess.call의 컬 문이Python에서 JSON 문자열을로드하는 중 오류가 발생했습니다.
이 기능
def curlopia(j_son=get_json()): sf_url = j_son['sf_sandbox_url']['url'] grant_type = j_son['oauth_parms']['grant_type'] client_id = j_son['oauth_parms']['client_id'] client_secret = j_son['oauth_parms']['client_secret'] username = j_son['oauth_parms']['username'] password = j_son['oauth_parms']['password'] param = '-d'
def get_json(): return json.load(open('environment.json', 'r'))
x=subrpocess.call(["curl", sf_url, param, "grant_type=%s" % (grant_type), param, "client_id=%s" % (client_id), param, "client_secret=%s" % (client_secret), param, "username=%s" % (username), param, "password=%s" % (password)])
또는
x=os.system('curl {0} -d "grant_type={1}" -d "client_id={2}" -d "client_secret={3}" -d "username={4}" -d "password={5}" -H "X-PrettyPrint:1"'.format(sf_url, grant_type, client_id, client_secret, username, password))
결과는 마지막 제로 후행를 x I 인쇄
. 왜{"id":"https://[email protected]/","issued_at":"xxxxxxxxxxx","token_type":"Bearer","instance_url":"xxxxxxxxxx","signature":"xxxxxxxxx","access_token":"xxxxxxxxxxxxx"}0
확실. 내가 할
json.loads(x)
나에게 아래의 오류를 제공합니다. 부하에서 또한 내가 시도 다양한 조합
파일 "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/ 초기화 평", 라인 (326), 반환 _default_decoder 디코드 OBJ 최종 = 자체에 .decode 발
파일 "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py"라인 (360) .raw_decode (s, idx = _w (s, 0) .end())
왜 후행 0이 있고 그 오류가 관련되어 있는지 이해하려고합니다. 누군가가 주위에 어쩌면 c 이것을하는 방법을 orrect.
감사합니다.
) 기존 컬 문에서 알게 될 것이다이, 끝 부분의 0은 그것을 깨뜨릴 것입니다. 당신이 '말장난'에 무엇을 가지고 있는지 전혀 모르겠다. –