我的Regex-fu严重缺乏,我无法解决……得到的任何帮助。
我正在寻找一种Python方式来解析一个旧的软件(我没有源代码访问权限)发出的字符串:
TypeError: descriptor 'append' requires a 'list' object but received a 'Profile'
我想做的是:
(1)删除所有现有的,Areas for further improvement,The school’s leaders are rightly seeking to improve the following areas:,,========2========,,3/5,Continue to focus on increasing performance at the higher levelsPupils’,literacy and numeracy skills across the curriculumStandards,in science throughout the schoolPupils’,numerical reasoning skills
字符以形成单个连续字符串:
, : = /
然后在每个大写字母前加上一个Areas for further improvementThe school’s leaders are rightly seeking to improve the following areas23/5Continue to focus on increasing performance at the higher levelsPupils’literacy and numeracy skills across the curriculumStandardsin science throughout the schoolPupils’numerical reasoning skills
,以允许我随后将该字符串用作明智的csv输入。...
,
我很高兴这可以给我一个先例,但是我可以在写入文件时将其删除。
可以通过,Areas for further improvement,The school’s leaders are rightly seeking to improve the following areas23/5,Continue to focus on increasing performance at the higher levels,Pupils’literacy and numeracy skills across the curriculum,Standardsin science throughout the school,Pupils’numerical reasoning skills
和正则表达式来实现吗?
(很高兴这是一个两步过程-删除现有的垃圾字符,然后添加,大写字母开头)
有人可以保存我的正则表达式吗?
欢呼
答案 0 :(得分:3)
re.sub(r'([A-Z])', r',\1', re.sub(r'[,:=/]', '', input_))
输出:
',Areas for further improvement,The school’s leaders are rightly seeking to improve the following areas235,Continue to focus on increasing performance at the higher levels,Pupils’literacy and numeracy skills across the curriculum,Standardsin science throughout the school,Pupils’numerical reasoning skills'
答案 1 :(得分:1)
您可以两次申请getCase ({ commit, context }, data) {
return axios.get('http' + data + '.json')
.then(res => {
const convertcase = []
for (const key in res.data) {
convertcase.push({ ...res.data[key], id: key })
}
//console.log(res.data) returns my record from firebase (doesnt display the key though in the array, just the fields within the firebase record, but assume this is expected?
commit('GET_CASE', convertcase)
})
.catch(e => context.error(e));
},
:
// Get Investigation
GET_CASE(state, caseId) {
state.caseId = caseId;
},
输出:
declare @ds varchar(40) = '2017-03-07T16:17:59.000+0000';
--set @ds = '2017-03-07T16:17:59.000'
declare @d datetime2 = '2017-03-07T16:17:59.000';
select @ds, @d
, convert(datetime2, replace(@ds,'+0000',''));