我当前的setup.py
脚本运行正常,但它将tvnamer.py
(工具)安装tvnamer.py
到site-packages或类似的地方..
我可以setup.py
安装tvnamer.py
的tvnamer
,和/或是否有安装命令行应用程序的更好的办法?
我有一个字典regionspointcount
,它将区域名称(str
)作为键,并将该区域内的一种特征类型(int
)作为值保存{'Highland':21}
.
我想在枚举时迭代字典的键和值.有没有办法做这样的事情:
for i, k, v in enumerate(regionspointcount.items()):
Run Code Online (Sandbox Code Playgroud)
或者我是否必须使用计数变量?
运行查询会按预期select date_part('week','2016-12-31'::date)
返回结果52
,因为这是 2016 年的最后一周。
运行查询会按预期select date_part('week','2017-01-02'::date)
返回结果1
,因为这是 2017 年的第一周。
但是,运行查询select date_part('week','2017-01-01'::date)
会返回52
错误的结果。
这与 2017-01-01 是星期日有关系吗?
我正在尝试从 SFTP 服务器复制文件。我可以使用 python pysftp 进行连接。我可以跑:
data = srv.listdir()
for i in data:
print I
Run Code Online (Sandbox Code Playgroud)
我得到了目录列表。但是当我尝试
sftp.put (localpath,"file_name.txt")
Run Code Online (Sandbox Code Playgroud)
我得到
“IOError:[Errno 13] 权限被拒绝:'C:\.....”
我对该文件夹有权限,因为我可以运行 MKDIR 并在该文件路径中创建一个目录。我已经尝试了许多不同的方法,但到目前为止没有运气,任何帮助都非常感谢。
import pysftp
import os
def sftpExample():
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
with pysftp.Connection('HOST', username='username', password='Password', cnopts=cnopts) as sftp :
print 'connected '
localpath="C:\\new project\\new"
remotepath="/folder1"
sftp.put(localpath,"infso.txt")
sftp.put(localpath,remotepath)
sftp.getfo (remotepath, localpath )
srv.get_r(localpath, remotepath)
srv.close()
sftpExample()
Run Code Online (Sandbox Code Playgroud)
我收到此错误代码:
Traceback (most recent call last):
File "db_backup.py", line 42, in <module>
sftpExample()
File "db_backup.py", line 17, in sftpExample …
Run Code Online (Sandbox Code Playgroud) 我正在制作传单地图。我正在加载一些 geoJSON 数据。我有地图的点击功能。当我单击时,我只想从加载的 geoJSON 中提醒最近的点。问题是,无论我在城市中的哪个位置单击,都只会返回一个点(下图所示的点。
//Create the map
var map = L.map('mapdiv').setView([-43.534384, 172.640528], 13);
// Add the basemap
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
// Create a variable that is the URL of the schools data
var url = 'https://koordinates.com/services/query/v1/vector.json?key=8dcaa116555f4ef1bfae391119119bdc&layer=243&x=172.640565&y=-43.534366&max_results=100&radius=100000&geometry=true&with_field_names=true';
// Get the data from the service and asign it to a variable
function httpGet(theUrl) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", theUrl, false); // false for synchronous request
xmlHttp.send(null);
return xmlHttp.responseText;
}
var schoolData = JSON.parse(httpGet(url)).vectorQuery.layers[243];
// …
Run Code Online (Sandbox Code Playgroud)我有以下函数,我已编写转换msSinceEpoch
为新西兰日期(IE11兼容)...
const MAGICNUMBER = 13;
const toNewZealand = (msSinceEpoch) => {
const [day, month, year, time] = new Date(msSinceEpoch).toLocaleString("en-NZ", {
hour12: false, timeZone: "UTC"
}).split(/[/,]/); // timeZone UTC is the only format support on IE11
const [hours, minutes, seconds] = time.trim().split(":");
return new Date(~~year, ~~month - 1, ~~day, ~~hours + MAGICNUMBER, ~~minutes, ~~seconds)
};
// usage....
console.log(
toNewZealand(new Date().getTime())
)
Run Code Online (Sandbox Code Playgroud)
但是,这包含一个与新西兰夏令时(+12或+13)无关的幻数.
所以这里变得复杂,如何在新西兰(+12或+13)获得相对于夏令时的正确数字.
我最初的尝试只是计算它是在9月的最后一个星期日还是在4月的第一个星期日之间,但后来我意识到第二个我new Date()
在代码中的任何地方使用构造函数,它将创建一个相对于系统时间和中断的日期数学.
TL; DR将自纪元以来的UTC毫秒转换为适用于新西兰夏令时设置的新西兰时间.
编辑:也不感兴趣使用Moment或任何其他库来解决此问题,因为捆绑大小成本.
python ×4
date ×2
javascript ×2
command-line ×1
continue ×1
dictionary ×1
enumerate ×1
geojson ×1
ioerror ×1
leaflet ×1
packaging ×1
permissions ×1
postgresql ×1
pysftp ×1
python-3.x ×1
sql ×1
turfjs ×1