加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

在Windows 7中打开带冒号(“:”)的文件名

发布时间:2020-12-13 20:42:25 所属栏目:Windows 来源:网络整理
导读:我正在编写一个应该在Windows和Linux上运行的Python应用程序,但我遇到了一个文件管理约定的问题.我需要加载一个名称中包含冒号的JSON文件.但是,对于Windows 7,它似乎不可能,至少不是直接的. 这些文件存储在NFS驱动器上,因此我们可以在Windows 7中看到它,但无
我正在编写一个应该在Windows和Linux上运行的Python应用程序,但我遇到了一个文件管理约定的问题.我需要加载一个名称中包含冒号的JSON文件.但是,对于Windows 7,它似乎不可能,至少不是直接的.

这些文件存储在NFS驱动器上,因此我们可以在Windows 7中看到它,但无法打开它们.

有没有人有一个解决方法,如何使用Python在Windows 7中读取包含冒号的JSON文件?我们有一个可能的解决方法(我们想避免)是通过SSH连接到Linux机箱,回显内容并将其发回.

显然,如果其他人有另一种方法会很棒. Windows XP能够打开它们并且读得很好 – 这只是Win 7的一个问题.

-edit-更新:我们发现我们可以通过网络访问我们的NFS / AFS服务器.所以我们最终使用urllib2 urlopen来处理包含无效字符的所有JSON文件.到目前为止似乎运作良好.

引用 http://support.microsoft.com/kb/289627:

Windows and UNIX operating systems have restrictions on valid characters that can be used in a file name. The list of illegal characters for each operating system,however,is different. For example,a UNIX file name can use a colon (:),but a Windows file name cannot use a colon (:). …

To enable file name character mapping,create a character translation file and add a registry entry.

For example,the following maps the UNIX colon (:) to a Windows dash (-):

0x3a : 0x2d ; replace client : with – on server

When you have created the file name character translation file,you must specify its name location in the system registry. To register the path and name of the file:

  • Use Registry Editor to locate the following registry key:
  • HKEY_LOCAL_MACHINESoftwareMicrosoftServer For NFSCurrentVersionMapping
  • Edit the CharacterTranslation (REG_SZ) value.
  • Enter the fully qualified path name of the file name character translation file. For example,C:SfuCTrans.txt.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读