Windows 上的倒斜杠以及 OS X 和 Linux 上的正斜杠
来源:互联网 发布:ps修复软件下载 编辑:程序博客网 时间:2024/05/02 18:06
Windows 上的倒斜杠以及 OS X 和 Linux 上的正斜杠
1. Windows
Microsoft Windows [版本 6.1.7601]版权所有 (c) 2009 Microsoft Corporation。保留所有权利。C:\Users\foreverstrong>pythonPython 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import os>>> os.path.join("usr", "include", "c++")'usr\\include\\c++'>>>>>> print(os.path.join("usr", "include", "c++"))usr\include\c++>>>>>>>>> files = ["a.txt", "b.txt", "c.txt"]>>> for filename in files:... print(os.path.join("C:\\Users\\Default", filename))...C:\Users\Default\a.txtC:\Users\Default\b.txtC:\Users\Default\c.txt>>>
请注意,倒斜杠有两个,因为每个倒斜杠需要由另一个倒斜杠字符来转义。
strong@foreverstrong:~$ pythonPython 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import os>>> os.path.join("usr", "include", "c++")'usr/include/c++'>>> >>> print(os.path.join("usr", "include", "c++"))usr/include/c++>>> >>> >>> files = ["a.txt", "b.txt", "c.txt"]>>> for filename in files:... print(os.path.join("/Users/Default", filename))... /Users/Default/a.txt/Users/Default/b.txt/Users/Default/c.txt>>> >>> >>> files = ["a.txt", "b.txt", "c.txt"]>>> for filename in files:... print(os.path.join("/Users/Default/", filename))... /Users/Default/a.txt/Users/Default/b.txt/Users/Default/c.txt>>> >>> >>> files = ["a.txt", "b.txt", "c.txt"]>>> for filename in files:... print(os.path.join("/Users/Default//", filename))... /Users/Default//a.txt/Users/Default//b.txt/Users/Default//c.txt>>> >>> >>> files = ["a.txt", "b.txt", "c.txt"]>>> for filename in files:... print(os.path.join("/Users/Default///", filename))... /Users/Default///a.txt/Users/Default///b.txt/Users/Default///c.txt>>>
阅读全文
0 0
- Windows 上的倒斜杠以及 OS X 和 Linux 上的正斜杠
- 正斜杠(/)和反斜杠(\)的区别
- 正斜杠 和发斜杠的用法
- 正斜杠(/)和反斜杠(\)的区别
- 正斜杠和反斜杠的区别
- 正斜杠和反斜杠的区别
- 正斜杠和反斜杠的区别
- python的正斜杠
- 正斜杠'\'和反斜杠'/'的区别及原因
- 路径里的正斜杠和反斜杠
- windows路径使用正斜杠的问题
- Linux下的正斜杠"/"和"\"的区别
- 正斜杠与反斜杠的分析
- 正斜杠与反斜杠的分析
- 正斜杠与反斜杠的讲解
- 正斜杠与反斜杠的区别
- 关于文件路径的反斜杠正斜杠和双斜杠问题
- 关于文件路径的反斜杠正斜杠和双斜杠问题
- IDEA构建一个mybatis项目
- SpringBoot
- 通过判断浏览器的userAgent,用正则来判断手机是否是ios(苹果)和Android(安卓)客户端
- 查看mysql库大小,表大小,索引大小
- 从文件里面读出1000个随机数,进行排序,再写到另一文件中。(考虑使用重定向dup/dup2)
- Windows 上的倒斜杠以及 OS X 和 Linux 上的正斜杠
- Jenkins入门系列之——02第二章 Jenkins安装与配置
- 视觉设计中发现的11种光学错觉
- Axure8.0
- VUE学习-环境搭建
- 《算法导论》11.3-3解答——k为按基数2^p表示的字符串。试证明:如果串x可由串y通过其自身的字符置换排列导出,则x和y具有相同的散列值。
- 基于Spring的 Redis工具类
- gdb调试Go,info goroutines
- 再谈连接数据库