我的代码在这里
str = "Early in his first term in office, Obama signed into law economic stimulus legislation in response"
arr= str.split(" ")
set_element= arr.each_cons(2).to_a
sub_str = set_element.map {|i| i.join(' ')}
Run Code Online (Sandbox Code Playgroud)
如果我有一个像大字符串这样的大字符串,那么这个过程需要6.50秒,因为我想要这种类型的结果
sub_str= ["Early in", "in his", "his first", "first term", "term in", "in office,", "office, Obama", "Obama signed", "signed into", "into law", "law economic", "economic stimulus", "stimulus legislation", "legislation in", "in response"]
Run Code Online (Sandbox Code Playgroud)
是否有可能采用其他有效方式
我有这个由第三方Web服务生成的JSON
{
"user_data": {
"123456789": {
"transactions_id": 123456789,
"transaction_date": "2015-07-08T18:31:28+01:00",
"reason_type": "REWARD",
"category": "categoryFoo",
"title": "titleFoo",
"description": "",
"reward_quantity": 5,
"reward_name": " foo"
},
"1234567891": {
"transactions_id": 1234567891,
"transaction_date": "2015-07-08T18:33:06+01:00",
"reason_type": "REWARD",
"category": "categoryFoo",
"title": "titleFoo",
"description": "",
"reward_quantity": 5,
"reward_name": " foo"
},
"1234567892": {
"transactions_id": 1234567892,
"transaction_date": "2015-07-08T18:35:00+01:00",
"reason_type": "REWARD",
"category": "categoryFoo",
"title": "titleFoo",
"description": "",
"reward_quantity": 5,
"issuers_name": " foo"
}
}
}
Run Code Online (Sandbox Code Playgroud)
交易金额将随着每个请求而变化,因此可能有3个像这样一次然后10个下一个.为了处理不同数量的事务,我理解您需要使用类似于此的列表public List<User> users { get; set; },用户与此类似
public class User
{
public …Run Code Online (Sandbox Code Playgroud) 遇到一个问题,我有一个空资源,该资源运行脚本来创建一段配置。整个 TF 需要在帐户的每个区域中运行,因此我已将所有内容设置为使用区域作为变量。
这导致 terraform 在区域 2 中创建新配置之前销毁区域 1 中的原始空资源配置。其他 terraform 资源仅在区域 2 中创建新资源,并将区域 1 中的资源保留在原处。有没有办法让空资源的行为与其他资源相同?
resource "null_resource" "config-s3-remediation" {
triggers = {
account_name = var.account_name
region = var.region
}
depends_on = [
aws_config_config_rule.s3_access_logging_rule,
aws_ssm_document.s3_access_logging_ssm
]
provisioner "local-exec" {
command = "python3 ${path.module}/remediation_config.py add ${self.triggers.region}
}
provisioner "local-exec" {
when = destroy
command = "python3 ${path.module}/remediation_config.py remove ${self.triggers.region}"
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个这样的字符串存储在mysql表中:
?name1=value1&name2=value2&name3=value3
最初这个数据只用于将GET数据发送到另一个脚本,但现在我发现自己需要它用于其他事情.
PHP中是否有预定义函数将这些对转换为变量或数组?或者我必须手动完成吗?
arrays ×2
c# ×1
json ×1
json.net ×1
list ×1
name-value ×1
php ×1
query-string ×1
ruby ×1
terraform ×1