如何将值与反斜杠进行比较? [英] How do I compare a value to a backslash?
本文介绍了如何将值与反斜杠进行比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if (message.value[0] == "/" or message.value[0] == "\"):
do stuff.
我确定这是一个简单的语法错误,但是这个 if 语句有问题.
I'm sure it's a simple syntax error, but something is wrong with this if statement.
推荐答案
转义反斜杠:
if message.value[0] == "/" or message.value[0] == "\\":
来自文档:
反斜杠 (\) 字符用于转义字符,否则有一个特殊的含义,例如换行符,反斜杠本身,或引用字符.
The backslash (\) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character.
这篇关于如何将值与反斜杠进行比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文