在变量前加上“_”是什么意思?

问题描述 投票:0回答:2

我注意到在不同语言的几个地方(

C++
Java
Python
...)使用
_variable
命名。这说明什么?

variables language-agnostic naming-conventions
2个回答
0
投票

在 c 或 c++ 中,_ 用于 lib 代码中使用的某些变量的变量名开头。以防止在您的代码和 lib 中找到相同的名称。 我 python _ 用于未分配给变量的结果。


0
投票

在 Python 中:

_ = 1
(_-_) will now equal 0
© www.soinside.com 2019 - 2024. All rights reserved.