请写一个python脚本用于 提取以下文件中函数中的参数及参数类型:FUNC(void, StartApplication_CODE) Appl_SccCbk_Get_ISO_20_TimeStamp( P2VAR(Exi_UInt64, AUTOMATIC, SCC_APPL_DATA) DataPtr) { *DataPtr = ApplTime_GetTime64(); } FUNC(void, StartApplication_CODE) Appl_SccCbk_Get_ISO_20CM_EVCCID( P2VAR(Exi_ISO_20_CT_10_identifierType, AUTOMATIC, SCC_APPL_DATA) DataPtr) { STARTAPPLICATION_DUMMY_STATEMENT(DataPtr); } FUNC(void, StartApplication_CODE) Appl_SccCbk_Get_ISO_20CM_SelectedAuthorizationService( P2VAR(Exi_ISO_20_CM_10_authorizationType, AUTOMATIC, SCC_APPL_DATA) DataPtr) { STARTAPPLICATION_DUMMY_STATEMENT(DataPtr); } FUNC(void, StartApplication_CODE) Appl_SccCbk_Get_ISO_20CM_GenChallenge( P2VAR(Exi_ISO_20_CM_10_genChallengeType*, AUTOMATIC, SCC_APPL_DATA) DataPtr) { STARTAPPLICATION_DUMMY_STATEMENT(DataPtr); }FUNC(void, StartApplication_CODE) Appl_SccCbk_Set_ISO_20CM_AuthorizationMode( P2CONST(Exi_ISO_20_CM_10_AuthorizationSetupResChoiceType, AUTOMATIC, SCC_APPL_DATA) DataPtr) { STARTAPPLICATION_DUMMY_STATEMENT(DataPtr); } FUNC(void, StartApplication_CODE) Appl_SccCbk_Set_ISO_20CM_SessionID(P2CONST(Exi_ISO_20_CT_10_sessionIDType, AUTOMATIC, SCC_APPL_DATA) DataPtr) { STARTAPPLICATION_DUMMY_STATEMENT(DataPtr); } FUNC(void, StartApplication_CODE) Appl_SccCbk_Set_ISO_20CM_EVSEID( P2CONST(Exi_ISO_20_CT_10_identifierType, AUTOMATIC, SCC_APPL_DATA) DataPtr) { STARTAPPLICATION_DUMMY_STATEMENT(DataPtr); } FUNC(void, StartApplication_CODE) Appl_SccCbk_Set_ISO_20CM_ServiceRenegotiationSupported(boolean Data) { /*If set to 锟絋rue锟� the SECC is capable of ServiceRenegotiation*/ Data = FALSE; }
时间: 2023-08-05 15:02:59 浏览: 92
python 函数中的参数类型
5星 · 资源好评率100%
可以使用正则表达式来提取函数参数及其类型,以下是示例代码:
```python
import re
# 读取文件内容
with open('filename.c', 'r') as f:
content = f.read()
# 定义正则表达式
pattern = r'FUNC\(.*\)\s*(\w+)\s*\((.*)\)\s*{'
# 查找匹配的函数
matches = re.findall(pattern, content, re.DOTALL)
# 提取参数及其类型
for func_name, params_str in matches:
params = params_str.split(',')
for param in params:
param = param.strip()
if param:
name, _, type_str = param.partition(' ')
print(name, type_str)
```
这个脚本会输出每个函数中的参数及其类型。注意,这个脚本只能提取形如示例中的函数定义,如果函数定义有变化,可能需要调整正则表达式。
阅读全文