小编use*_*334的帖子

超时后恢复FTP下载

我从文件传输过程中经常超时的片状FTP服务器下载文件,我想知道是否有办法重新连接并恢复下载.我正在使用python的ftplib.这是我正在使用的代码:

#! /usr/bin/python

import ftplib
import os
import socket
import sys

#--------------------------------#
# Define parameters for ftp site #
#--------------------------------#
site           = 'a.really.unstable.server'
user           = 'anonymous'
password       = 'someperson@somewhere.edu'
root_ftp_dir   = '/directory1/'
root_local_dir = '/directory2/'

#---------------------------------------------------------------
# Tuple of order numbers to download. Each web request generates 
# an order numbers
#---------------------------------------------------------------
order_num = ('1','2','3','4')

#----------------------------------------------------------------#
# Loop through each order. Connect to server on each loop. There #
# might be a time out for the connection therefore reconnect …
Run Code Online (Sandbox Code Playgroud)

python ftp resume timeout

6
推荐指数
1
解决办法
3909
查看次数

基于列表对字典的值进行排序

我想基于其中一个列表对字典的值(列表)进行排序.比如说我有字典:

data = {'AttrA':[2,4,1,3],'AttrB':[12,43,23,25],'AttrC':['a','d','f','z']}
Run Code Online (Sandbox Code Playgroud)

我想根据与AttrA相关的值对此进行排序,这样:

data = {'AttrA':[1,2,3,4],'AttrB':[23,12,25,43],'AttrC':['f','a','z','d']}
Run Code Online (Sandbox Code Playgroud)

先感谢您!

python sorting dictionary

1
推荐指数
1
解决办法
152
查看次数

在Fortran中重载子例程和函数

是否可以使用接口块重载子例程和函数?因此可以通过函数或子例程调用过程.例如:

...
interface TestRoutine
      module procedure TestRoutine_fun
      module procedure TestRoutine_sub
end interface TestRoutine

Contains

function TestRoutine_fun(....) result(...)
...
end function TestRoutine_fun

subroutine TestRoutine_sub(...)
...
end subroutine TestRoutine_sub
...
Run Code Online (Sandbox Code Playgroud)

当我尝试编译类似于此的代码时,我得到了错误:错误:在通用接口'TestRoutine'中(1),程序必须是所有SUBROUTINES或所有FUNCTIONs.提前致谢!

fortran overloading interface function subroutine

1
推荐指数
1
解决办法
676
查看次数