이 코드를 사용하고 있습니다 :동일한 함수는 파이썬에서 반대 순서로 다른 결과를 제공합니다. 왜?
def copy_part_of_space(row,column,lenght):
#Copy String to Presentation Space (15)
#Prerequisite Connect Presentation Space
#Prerequisite function: connect_pcomm(presentation_space)
function_number = c_int(8)
data_string = create_string_buffer(lenght*2*2) #number of unicode char *2*2
lenght = c_int(lenght)
ps_position = c_int(((row - 1) * 80)+ column)
foo = hllapi(byref(function_number), data_string, byref(lenght), byref(ps_position))
data_string.value
return {{
0 : 'The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.',
1 : 'Your program is not connected to a host session.',
4 : 'The host presentation space contents were copied. The connected host presentation space was waiting for host response.',
5 : 'The host presentation space was copied. The keyboard was locked.',
9 : 'A system error was encountered.',
'x' : 'Undocumented error found. Run in circles.',
}.get(foo, 'x'),data_string.value}
아이디어 터미널에서 일부 정보를 복사하는 것입니다; 함수는 상태 정보를 반환해야합니다 (사전 및 0,1,4,5,9, x 매개 변수 사용). 그리고 복사 된 정보 - data_string.value 사용
몇 가지 테스트를 실행하려면 다음 코드를 사용합니다. 위의 기능 : - 첫 번째 줄처럼 당신이 볼 수 있듯이
set(['The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.', '36343581'])
set(['36343663', 'The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.'])
set(['The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.', '36343708'])
set(['36344673', 'The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.'])
set(['36344740', 'The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.'])
set(['The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.', '36344758'])
set(['36344869', 'The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.'])
가, 때로는 호스트 응용 프로그램에서 복사 한 것을 이전 상태 정보를 얻을 :
for a in range(15,22):
print copy_part_of_space(a,7,8)
이 결과입니다.
하지만 때로는 상태 정보 앞에 복사 된 정보 (예 : 2 행)가 표시됩니다.
나는 정보를 반환하는 dict
를 사용하여와 하지 잘 알고, 그래서 내가 특별히 내가 두 변수를 반환하기 위해 노력하고있어 사실과 혼합 할 때, 그 문제가 될 수도 있겠죠.
왜 이런 일이 일어날 지 설명 할 수 있습니까?
나는 단순히 dict
을 사용하고 반환 값을 변수에 저장하기 만하면되지만, 실제로 이것이 더 우아한 해결책이라고 생각합니다. 틀렸습니까?
'그들의 순서는 arbitrary'하지만, 당신이 일을 할 때 바뀔 수도있다. – katrielalex
이 경우에 할 일은 튜플을 반환하는 것이다. –
@MarkRansom :'set' 생성자가 제거 될 때 어떤 일이 발생합니다. –