“\\”之间有什么区别?和“”在Erlang [英] What is the difference between \" and "" in Erlang

查看:180
本文介绍了“\\”之间有什么区别?和“”在Erlang的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Erlang中, \是一个转义字符,表示双引号。

In Erlang, \" is an escape character that means double quote.

我的问题是, \test \test之间有什么区别?问是因为,我正在尝试处理一个 list_to_atom 错误:

My question is, what is the difference between "\"test\"" and ""test""? The reason I ask is because, I'm trying to handle a list_to_atom error:

> list_to_atom("\"test\"").
'"test"'
> list_to_atom(""test"").
* 1: syntax error before: test


推荐答案

/ code>是长度为0的字符串/列表

"" is a string/list of length 0

\只是一个转义的双-quote当在字符串的上下文中使用时。如果你想要一个只包含一个双引号(即 \)的字符串,那么你可以这样做:\

\" is just an escaped double-quote when used in the context of a string. If you wanted to have a string that consists of just a double-quote (ie \"), then you could do: "\"".

test是语法错误,没有区别比test在语法上< list>< atom>< list> 。你想完成什么?

""test"" is a syntax error and is no difference than "" test "" which is syntactically <list><atom><list>. What are you trying to accomplish?

这篇关于“\\”之间有什么区别?和“”在Erlang的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆