2013-01-25 1 views
0
latitude = bytes([data[12],data[11],data[10],data[9]]) 
     longitude = bytes([data[16],data[15],data[14],data[13]]) 

     intLat = struct.unpack('!f',latitude) 
     intLong = struct.unpack('!f',longitude) 

     print(intLat) 
     print(intLong) 

이것은 인쇄 된 코드입니다.()와 (을)를 제거하는 방법

(100.47630310058594,) 
(5.136366844177246,) 

() 및? 난 그냥 원하기 때문에 당신이 튜플의 첫 번째 요소를 참조 할 필요 아웃()와 함께 데이터베이스에

+3

intLat = struct.unpack ('! f', 위도) [0]'할 것입니다! – inspectorG4dget

답변

2

를 저장하기 위해 부동 :

intLat = struct.unpack('!f',latitude)[0] 
intLong = struct.unpack('!f',longitude)[0] 
0
(100.47630310058594,) 

이것은 데이터가 tuple 의미 하나의 요소 만 있으면됩니다. 목록과 마찬가지로 색인을 생성하여 데이터를 가져올 수 있습니다.

intLong[0] 

이 데이터를 가져옵니다.

또는 단순히 언급 된 휘발성으로 출력 압축을 풀 수 있습니다.

+0

@AshwiniChaudhary 감사합니다. – ATOzTOA

관련 문제