python函数调用参数问题

def example(a, b, c=100):
… a = 1 # notice here I am assigning ‘a’
… b = 2 # and here the value of ‘b’ is being overwritten
… # The value of c is set to 100 by default
… print(a,b,c)

example(4,5) # Here I am passing in 4 for a, and 5 for b
(1, 2, 100) # but notice its not taking any effect

example(9,10,11) # Here I am passing in a value for c
(1, 2, 11)

可以进一步参考这篇博文,原文链接

展开阅读全文

函数调用参数问题!!!!!

04-25

有三个函数,连续执行,前两个没问题,到第三个就出问题了,那位兄弟帮我看看啊,谢谢了!!!!!!!!rnrnrn函数原型: rnHHNET_Startup(IN HWND hNotifyWnd,rn IN UINT nCommandID ,rn IN DWORD dwFrameBufNum= 0, rn IN BOOL bReadyRelay= FALSE,rn IN BOOL bReadyCenter= FALSE,rn IN char *pLocalAddr= NULL); rn在DELPHI中rn function HHNET_Startup(hNotifyWnd:HWND; //启动网络服务rn nCommandID:Cardinal;rn dwFrameBufNum:DWORD;rn bReadyRelay:boolean;rn bReadyCenter:boolean;rn pLocalAddr:PCharrn ):Integer;stdcall;external 'HHNetClient.dll' name 'HHNET_Startup' ;rnrn Handle := Form1.Handle ;rn nCommandID := WM_USER + 100 ;rn fhz := HHNET_Startup(Handle,nCommandID,0,false,false,PChar('10.136.72.118')) ;rn-----------------执行返回值为0,正确。rn函数原型rnHHNET_LogonServer(IN char *pServerIP,rn IN UINT nServerPort,rn IN char *pDeviceName,rn IN char *pUserName,rn IN char *pUserPassword,rn IN DWORD wClientID,rn OUT HANDLE &hLogonServer,rn IN HWND hNotifyWindow = NULL);rn在DELPHI中rn function HHNET_LogonServer(pServerIP:PChar; //登陆服务器rn nServerPort:Cardinal;rn pDeviceName:PChar;rn pUserName:PChar;rn pUserPassword:PChar;rn wClientID:Cardinal;rn var hLogonServer:THANDLE;rn hNotifyWindow:HWND):Integer;stdcall;external 'HHNetClient.dll' name 'HHNET_LogonServer';rnrn HLogonServer : Thandle ;rnrnfhz := HHNET_LogonServer(PChar('10.136.72.128'),5000,PChar('DVS87528'),PChar('admin'),PChar('admin'),0,hLogonServer,Handle);rn----------执行函数返回值为0,正确。rnrn函数原型:rnHHNET_GetServerConfig( IN HANDLE hServer,rn IN HHCMD_NET nConfigCommand,rn OUT char *pConfigBuf,rn IN OUT UINT &nConfigBufSize,rn IN OUT DWORD *pAppend=NULL);rnrn在DELPHI中rn function HHNET_GetServerConfig(hServer:THANDLE;rn nConfigCommand:HHCMD_NET;rn pConfigBuf:PChar;rn var nConfigBufSize:Cardinal ;rn pAppend:PDWORD):Integer;stdcall;external 'HHNetClient.dll' name 'HHNET_GetServerConfig';rnrn typern user_config = packed Recordrn Level:DWORD;rn name:String[16];rn password:String[16] ;rn end;rnrn pConfigBuf : PChar ;rn nConfigBufSize : Cardinal ;rn pAppend : PDWORD ;rnrn nconfigBufSize := SizeOf(user_config) ;rnrnfhz := HHNET_GetServerConfig(hLogonServer,HHCMD_GET_USER_CONFIG,pConfigBuf,nconfigBufSize,pAppend) ;rn----执行后返回值是100,相应的错误代码是HERR_INVALID_PARAMETER =100, //输入参数无效rnrnHHCMD_NET是一个枚举类型rnrnrn那位达人帮我看看,谢谢了啊!!!!!!!! 论坛

没有更多推荐了,返回首页