我对这段代码有疑问:
import optparse
parser = optparse.OptionParser(version=__version__,
usage="%prog [options] file1 ... host[:dest]",
description=main.__doc__)
parser.add_option("-c", "--config", help="Specify an alternate config "
"file. Default = '%s'" % config_file)
parser.add_option('-l', '--log-level', type="choice",
choices=LOG_LEVELS.keys(),
help="Override the default logging level. Choices=%s, Default=%s" %
(",".join(LOG_LEVELS.keys()), LOG_LEVEL))
parser.add_option("-o", "--overwrite", action="store_true",
help="If specified, overwrite existing files at destination. If "
"not specified, throw an exception if you try to overwrite a file")
parser.add_option('-s', "--speed", action="store_true", \
help="If specifed, print the data transfer rate for each file "
"that is uploaded (infers verbose option)")
parser.add_option('-v', '--verbose', action="store_true",
help="If specified, print every file that is being uploaded and every "
"directory that is being created")
parser.add_option("-u", "--user", help="The username to use for "
"authentication. Not needed if you have set up a config file.")
parser.add_option("-p", "--password", help="The password to use for "
"authentication. Not needed if you have set up a config file.")
parser.set_defaults(config=config_file, log_level=LOG_LEVEL)
options, args = parser.parse_args()
print (args)
如您所见,当我打印我们正在使用希伯来命名文件进行的测试时,打印结果包括: ['/root/mezeo_sdk/1/\xfa\xe5\xeb\xf0\xe9\xfa \xf2\ xe1\xe5\xe3\xe4.xlsx', 'hostname'] 而不是 /root/mezeo_sdk/1/"תוכנית עבודה.xlsx"
此外,一旦脚本将文件上传到服务器(传递文件名的方式),最终结果是:http: //i.imgur.com/pP6fA.png
文件名本身在 linux 源上很好,因为如果我将它 SCP 到我自己的计算机上,它看起来还不错,但一旦我使用 python 脚本将它传输到文件服务器就不行了。
我也不相信问题出在文件服务器端,因为如果我使用 Web 界面上传希伯来命名文件,它们就可以了。
我认为问题在于 optparse 库的使用。