分类目录

链接

2024 年 4 月
1234567
891011121314
15161718192021
22232425262728
2930  

近期文章

热门标签

新人福利,免费薅羊毛

python静态变量赋值

使用dir获取所有属性(包含静态),使用Exce赋值   import json     class Article(object):     title = None     link = None     abstract = None     keywords = []     content = None     pub_date = None     xxx = '99999'       def __init__(self):         for p in dir(self):             if not p[0:2] =='__':                 exec('self.'+p+' = Article.'+p)           pass                    a = Article() print(a.__dict__) output:  {'abstract': None, 'content': None, 'keywords': [...

Python 暂无评论 阅读(49)

c# 反射赋值扩展方法

public static T ToModel<T>(this object source) where T : class, new() { var target = new T(); if (source == null) return null; foreach (var property in target.GetType().GetProperties()) { var sourceProterty = source.GetType().GetProperty(property.Name); if (sourceProterty == null) { continue; }   var propertyValue = sourceProterty.GetValue(source, null);   if (propertyValue != null) {   //property.SetValue(target, i, null); target.GetType().InvokeMember(property.Na...

.NET 暂无评论 阅读(1,376)