datetime
now_time = time.localtime(time.time()) //获取现在时间
time = 20200813140000
time = datetime.datetime.strptime(time, '%Y%m%d%H%M%S') /转datetime 2020-08-13 14:00:00
time = time.strftime('%Y%m%d%H00') / 202008131400
foretime_hour = time.strftime('%H') / 14
foretime = (foretimes - datetime.timedelta(hours=9)).strftime("%Y%m%d%H0000") /时间的加减
json
surf_data = json.loads(response.decode("utf8")) //utf8读取
json.dump(return_data, fore_data) //写入
pip
pip install -i pypi.tuna.tsinghua.edu.cn/simple //pip清华源
插值
def interpolation_rain(lon, lat, data):
olon = np.linspace(115.3, 117.59, 230) # 经纬坐标,0.01
lon2 = olon
olat = np.linspace(39.3, 41.1, 181) # 纬度坐标,0.01°分辨率
lat2 = olat
olon, olat = np.meshgrid(olon, olat) # 生成坐标网格 meshgrid网格化
func = Rbf(lon, lat, data, function='linear') # 插值函数 调用Rbf插值函数中的 cubic 插值法linear
data_new = func(olon, olat) # 插值
data_new[data_new <= 0] = 0.0
return lon2, lat2, data_new
function='linear'情况下不能出现重复数据
tata_new[i] = [lati][loni]
服务器
chmod u+x chazhi.py /执行权限
vim编辑器下:
:set ff 或 :set fileformat
可以查看到当前的格式(fileformat=dos 或 fileformat=unix)
修改格式为unix
:set ff=unix或者 :set fileformat=unix
:wq保存退出
./test.py
MYSQL
select_sql = 'select * from theaty_station'
data = helper.fetchall(select_sql)
delete_sql = 'delete from theaty_station where id = %s'
result = helper.delete(delete_sql,delete_data)
update_sql = 'update theaty_station_data set max_wind = %s, pre_1h = %s, con_pre = %s, ave_tem = %s, sufr_tem = %s, update_time = %s where id = %s;'
update_data = []
data = helper.updateAll(update_sql, update_data)
杂记
ssl._create_default_https_context = ssl._create_unverified_context
开方 **
SyntaxError: Non-ASCII character '\xe6