slash

Difference between forward slash (/) and backslash (\) in file path

∥☆過路亽.° 提交于 2019-11-26 08:55:19
问题 I was wondering about the difference between \\ and / in file paths. I have noticed that sometimes a path contains / and sometimes it is with \\ . It would be great if anyone can explain when to use \\ and / . 回答1: / is the path separator on Unix and Unix-like systems. Modern Windows can generally use both \ and / interchangeably for filepaths, but Microsoft has advocated for the use of \ as the path separator for decades. This is done for historical reasons that date as far back as the 1970s

Forward slash or backslash?

倖福魔咒の 提交于 2019-11-26 08:29:48
问题 I am looking to write and read text files to and from (respectively) a directory different from that of my program. When I specify a directory to write to or read from, should I be using forward slashes or backslashes to identify a file path? 回答1: Using forward slashes will make it system independent. I'd stick to that for simplicity. Consider using java.io.File.separator if you ever display the path to the user. You'd rather not surprise those Windows users. They're a jumpy lot. 回答2: I've

Python Replace \\ with \

夙愿已清 提交于 2019-11-26 08:13:26
问题 So I can\'t seem to figure this out... I have a string say, \"a\\\\nb\" and I want this to become \"a\\nb\" . I\'ve tried all the following and none seem to work; >>> a \'a\\\\nb\' >>> a.replace(\"\\\\\",\"\\\") File \"<stdin>\", line 1 a.replace(\"\\\\\",\"\\\") ^ SyntaxError: EOL while scanning string literal >>> a.replace(\"\\\\\",r\"\\\") File \"<stdin>\", line 1 a.replace(\"\\\\\",r\"\\\") ^ SyntaxError: EOL while scanning string literal >>> a.replace(\"\\\\\",r\"\\\\\") \'a\\\\\\\\nb\'

Is it possible to use “/” in a filename?

不羁的心 提交于 2019-11-26 01:42:59
问题 I know that this is not something that should ever be done, but is there a way to use the slash character that normally separates directories within a filename in Linux? 回答1: The answer is that you can't, unless your filesystem has a bug. Here's why: There is a system call for renaming your file defined in fs/namei.c called renameat : SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname) When the system call gets invoked, it does a

Is it possible to use “/” in a filename?

末鹿安然 提交于 2019-11-25 19:27:52
I know that this is not something that should ever be done, but is there a way to use the slash character that normally separates directories within a filename in Linux? The answer is that you can't, unless your filesystem has a bug. Here's why: There is a system call for renaming your file defined in fs/namei.c called renameat : SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname, int, newdfd, const char __user *, newname) When the system call gets invoked, it does a path lookup ( do_path_lookup ) on the name. Keep tracing this, and we get to link_path_walk which has this: