所以贝司我有这个包含一长串数据的列表(字符串的长度可能会有所不同):
['{0 1} {1 5} {1 8} {1 10} {2 5} {2 7} {2 4} {3 4} {4 9} {5 6}']
我需要这个:
[[0,1],[1,5],[1,8],[1,10],[2,5],[2,7],[2,4],[3,4],[4,9],[5,6]]
但我完全不知道如何做到这一点......任何想法?
答案 0 :(得分:2)
您可以将//Get an instance of S3 Client. This is one one to do it:
$s3Client = new S3Client([
'version' => 'latest',
'region' => 'us-west-2', //Region of the bucket
'credentials' => array(
'key' => 'YOUR-ACCOUNT-KEY',
'secret' => 'YOUR-ACCOUNT-SECRET',
)
]);
//Get a command to GetObject
$cmd = $s3Client->getCommand('GetObject', [
'Bucket' => 'YOUR-BUCKET-NAME',
'Key' => 'YOUR-FILE-KEY'
]);
//The period of availability
$request = $s3Client->createPresignedRequest($cmd, '+10 minutes');
//Get the pre-signed URL
$signedUrl = (string) $request->getUri();
与ast.literal_eval
一起使用:
str.replace
答案 1 :(得分:1)
选项1:删除最外面的大括号,然后在angular-cli.json
上拆分,再在空格上拆分:
"} {"
选项2:使用正则表达式:
text = '{0 1} {1 5} {1 8} {1 10} {2 5} {2 7} {2 4} {3 4} {4 9} {5 6}'
result = [[int(num) for num in group.split()] for group in text[1:-1].split('} {')]
# [[0, 1], [1, 5], [1, 8], [1, 10], [2, 5], [2, 7], [2, 4], [3, 4], [4, 9], [5, 6]]