正斜杠/,反斜杠
正斜杠,
作为运算符,表示除号
在Mac和Unix上,表示路径分隔符
在网址URL中,表示路径分隔符
在日常文字中,表示顿号
反斜杠,
在Windows平台上,表示路径分隔符
What is the difference between a backslash and a forward slash?
Answer: The term "backslash" is on of the most incorrectly used terms in computing. People often refer to forward slashes as backslashes, especially when referring to URLs. Web addresses (URLs), such as http://pc.net/helpcenter/, contain forward slashes, rather than backslashes. The difference between a backslash and a forward slash is defined below:
Backslash:
Forward Slash: /
A good way to remember the difference between a backslash and a forward slash is that a backslash leans backwards ( ), while a forward slash leans forward ( / ).
In Windows, backslashes are used to separate directories in file paths (ex: C:Program FilesCommon Filesmicrosoft shared). On Mac and Unix systems, forward slashes are used for the same purpose (ex: /System/Library/Screen Savers).
Forward slashes can also be called simply "slashes," since they are much more commonly used than backslashes. (Slashes are also used as division symbols and in place of the word "or.") Therefore, the URL http://pc.net/helpcenter/ could be verbalized, "PC dot net slash help center." If you say "backslash" when sharing a URL, people will know what you mean, but you might come across as a noob. Therefore, it's best to get in the habit of using the correct term.
Backslash () vs. Forward Slash (/)
Return to Phill Conrad's: home page CS8 page CS16 page
Introduction
In working with many software tools, programming languages and operating systems, it is crucial to distinguish between backslash and forward slash. Here's a way to remember which one is which.
Imagine the cursor walking across the screen as a person.
In English, we write from left to right. So the cursor moves across the screen from left to right as we type, like this:
Imagine that cursor as a person, facing in the direction he/she is walking:
Now:
- if the person leans backward, he/she looks like a backslash
- if the person leans forward, he/she looks like a forward slash
Applications
Backslash is used for:
- file names in DOS and Windows,
- e.g.
C:Python31python.exe
,C:cs8cTurtle.py
- e.g.
- escape sequences in C, Unix, and other languages/systems that borrow the same syntax (C++, Java, etc.)
- for example
n
means newline,t
means tab
- for example
Forward slash is used for:
- File names in Unix (and Mac OS X, since it is derived from Unix), e.g.
/cs/student/jsmith/cs8/lab00
,/
Users/Shared/cs8/cTurtle.py
- Web addresses (URLs) such as
http://www.cs.ucsb.edu/~pconrad/cs8
- Dividing in many progamming languages, e.g.
battingAvg = hits / atBats;