本文共 1628 字,大约阅读时间需要 5 分钟。
idea提醒不区分大小写
This is just a very brief reminder about something you might run into when you’re trying to get your code to work on multiple platforms – in this case, OS X, Linux and Windows.
这只是一个简短的提醒,提醒您在尝试使代码在多个平台(例如OS X,Linux和Windows)上运行时可能遇到的问题。
Basically: file names/paths are case-sensitive on Linux, but not on OS X or Windows.
基本上:文件名/路径在Linux上区分大小写,但在OS X或Windows上不区分大小写。
Therefore, you could have some Python code like this:
因此,您可能会有类似以下的Python代码:
f = open(os.path.join(base_path, 'LE72020252003106EDC00_B1.tif'))f = open(os.path.join(base_path, 'LE72020252003106EDC00_B1.tif'))
which you might use to open part of a Landsat 7 image – and it would work absolutely fine on OS X and Windows, but fail on Linux. I initially assumed that the failure on Linux was due to some of the crazy path manipulation stuff that I had done to get base_path
– but it wasn’t.
您可以使用它来打开Landsat 7映像的一部分–它在OS X和Windows上绝对可以正常运行,但在Linux上则无法运行。 我最初以为Linux上的失败是由于我为获取base_path
所做的一些疯狂的路径操纵而base_path
,但事实并非如此。
It was purely down to the fact that the file was actually called LE72020252003106EDC00_B1.TIF
, and Linux treats LE72020252003106EDC00_B1.tif
and LE72020252003106EDC00_B1.TIF
as different files.
纯粹是因为该文件实际上称为LE72020252003106EDC00_B1.TIF
,而Linux将LE72020252003106EDC00_B1.tif
和LE72020252003106EDC00_B1.TIF
视为不同的文件。
I’d always known that paths on Windows are not case-sensitive, and that they are case-sensitive on Linux – but I’d naively assumed that OS X paths were case-sensitive too, as OS X is based on a *nix backend, but I was wrong.
我一直都知道Windows上的路径不区分大小写,而在Linux上则区分大小写-但我天真地认为OS X路径也区分大小写,因为OS X基于* nix后端,但我错了。
翻译自:
idea提醒不区分大小写
转载地址:http://zwhwd.baihongyu.com/