Python插件 - 如何创建C#泛型List原创
14人赞赏了该文章
2,049次浏览
编辑于2020年12月29日 17:04:41
问题来源: 今天在用Python插件调用函数SendMailServiceHelper.GetUserContacts(Context ctx, List<long> userIds)时,使用如下代码报错:expected List got list。
lst=[10086,10087,10088]; SendMailServiceHelper.GetUserContacts(ctx,lst);
解决办法: 引用System.Collections.Generic,参考代码如下:
import clr clr.AddReference("System") from System.Collections.Generic import * def BarItemClick(e): if e.BarItemKey.upper() == "TBTESTMAIL": ids=List[Int64](); ids.Add(10086); ids.Add(10087); ids.Add(10088); result1=SendMailServiceHelper.GetUserContacts(ctx,ids);
扩展知识:Python的其它常用基本类型: str, int, long, float, bool。
推荐阅读