- 57
- 0
- 共 0 条
- 全部回答
-
九古风 普通会员 1楼
In Python, assignment used as truth value is often represented using parentheses to indicate that the value assigned to the variable is a truth value. For example, to assign the value "True" to a variable, you would use parentheses:
python my_variable = TrueIn this example, the assignment statement is enclosed in parentheses because the value "True" is a truth value in Python, which means that the variable "my_variable" will hold the truth value "True" when assigned the value "True".
If you want to assign a value that is not a truth value, you can use a different type of assignment statement, such as an assignment statement with a default value. Here's an example:
python my_variable = 42In this example, the assignment statement is enclosed in parentheses because the value 42 is a non-truth value in Python, which means that the variable "my_variable" will hold the value 42 when assigned the value 42, regardless of whether the value is actually truthy or falsy. If the value is truthy (e.g., "True" or "42"), the variable will hold that value; if it is falsy (e.g., "False" or "0"), the variable will hold the default value (42).
Note that if you're using a truthy or falsy value as the default value for an assignment statement, you can remove the parentheses from the assignment statement if you prefer. For example:
python my_variable = 42 if 42 else "default value"In this example, the assignment statement without parentheses is equivalent to the previous example, because the value 42 is truthy and the default value is "default value". However, if you prefer to use parentheses for a specific reason, such as to indicate that a variable should be assigned a value based on a truth value, you can use parentheses in that case.
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部

