有没有类似Python的str.isidentifier
的:
>>> "foo".isidentifier()
True
>>> "42".isidentifier()
False
最佳答案
在 Erlang 中,原子用于表示常量值。
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V7.0 (abort with ^G)
1> is_atom(sunday).
true
2> is_atom('sunday').
true
3> is_atom("sunday").
false
4>
而且,erlang 中没有string
类型。 string
只是一个整数列表。
8> B = [115,117,110,100,97,121].
"sunday"
9> is_list(B).
true
10>
关于erlang - 如何知道原子或字符串是否是有效标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41072154/