def merge_dicts(*dict_args):
"""
Given any number of dicts, shallow copy and merge into a new dict,
precedence goes to key value pairs in latter dicts.
"""
result = {}
for dictionary in dict_args:
result.update(dictionary)
return result
z = merge_dicts(a, b, c, d, e, f, g)
package main
import (
"fmt"
"log"
"time"
)
func main() {
x_time := "Mon, 22 Jan 2018 19:21:00 +0300"
t, err := time.Parse("Mon, 02 Jan 2006 15:04:05 -0700", x_time)
if err != nil {
log.Fatal(err)
}
fmt.Println(t)
}
type AutoGenerated []struct {
Num1 struct {
Items struct {
M4A4 struct {
D []struct {
T []int `json:"t"`
F float64 `json:"f"`
U string `json:"u"`
I string `json:"i"`
} `json:"d"`
E string `json:"e"`
M struct {
R int `json:"r"`
C int `json:"c"`
T int `json:"t"`
} `json:"m"`
P int `json:"p"`
A int `json:"a"`
X int `json:"x"`
Q int `json:"q"`
} `json:"M4A4"`
} `json:"items"`
} `json:"1"`
Num2 struct {
Items struct {
M4A4 struct {
D []struct {
T []int `json:"t"`
F float64 `json:"f"`
U string `json:"u"`
I string `json:"i"`
} `json:"d"`
E string `json:"e"`
M struct {
R int `json:"r"`
C int `json:"c"`
T int `json:"t"`
} `json:"m"`
P int `json:"p"`
A int `json:"a"`
X int `json:"x"`
Q int `json:"q"`
} `json:"M4A4"`
} `json:"items"`
} `json:"2"`
}
AJAX¶
While the above method can be used for AJAX POST requests, it has some inconveniences: you have to remember to pass the CSRF token in as POST data with every POST request. For this reason, there is an alternative method: on each XMLHttpRequest, set a custom X-CSRFToken header to the value of the CSRF token. This is often easier, because many JavaScript frameworks provide hooks that allow headers to be set on every request.
with open('aa.txt', 'r') as file:
data = file.readlines()
for i,n in enumerate(data):
print(data[i][-2])
if data[i][-2] == '9':
data[i] = 'a\n'
print(data)
with open('aa.txt', 'w') as file:
file.writelines( data )