我有一本字典,我想用这个模式重命名所有键(测试编号 1 => testNumber1)
这是我的命令:
{'id': '4', 'event title': 'Coldplay World Tour', 'event start date': '29/07/2022 20:30', 'event end date': '30/07/2022 01:00', 'name of the location hosting the event (optional)': 'Stade de France', 'address of the location': '93200 Saint-Denis', 'total ticket number': '10000', 'maximum tickets per user': '6', 'sale start date': '04/05/2022', 'line up': '', 'asset url': 'https://coldplay.com/coldplay_asset.mp4'}
Run Code Online (Sandbox Code Playgroud)
在另一个 json -i 上,我做了这 2 个元素:
self.json_informations[i]['smart_contract']['collectionName'] = self.json_informations[i]['smart_contract'].pop('collection name') #on remplace collection par collectionName
Run Code Online (Sandbox Code Playgroud)
但更改所有参数会太长(而且不太灵活)。0
我也尝试了一个循环,但它不起作用:
for j in range(len(self.json_informations[0])): #my …Run Code Online (Sandbox Code Playgroud) 我有一个 json 模板,我想自动填充。
currently i do it manually like this:
for i in range(len(self.dict_trie_csv_infos)):
self.template_json[i]['name'] = self.dict_trie_csv_infos[i]['name']
self.template_json[i]['title'] = self.dict_trie_csv_infos[i]['title']
self.template_json[i]['startDateTime'] = self.dict_trie_csv_infos[i]['startDateTime']
self.template_json[i]['endDateTime'] = self.dict_trie_csv_infos[i]['endDateTime']
self.template_json[i]['address'] = self.dict_trie_csv_infos[i]['address']
self.template_json[i]['locationName'] = self.dict_trie_csv_infos[i]['locationName']
self.template_json[i]['totalTicketsCount'] = self.dict_trie_csv_infos[i]
.....etc..
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,它们具有相同的密钥名称,我尝试使用循环来完成此操作,但没有成功。
我怎样才能自动填写(是否可能)?
感谢您的回答
我是新手,Haskell我正在尝试拥有elem我的第一个[[char]]
我试过这个:(在我的主要)
tmpList = recomposeNumber (words argss) []
det = test tmpList
Run Code Online (Sandbox Code Playgroud)
tmpList 是一个 [[Char]]
我的tmpList是:
["12","+","1"]
Run Code Online (Sandbox Code Playgroud)
我尝试了类似的事情,但我不知道该怎么做
test:: [[Char]] -> [[Char]]
test [x:xs] = x
Run Code Online (Sandbox Code Playgroud)
我不知道它是否可能,但我想返回一个 integer
我想用测试函数返回“12”,但我迷路了