python - Python if 语句在使用随机输入端口时出错
问题描述
我正在尝试使用 if 语句来确定某个文本是否在输入中,并且在我使用输入随机之前它曾经可以正常工作,现在我的 if 语句返回语法错误。
command_1=input()
post_type_fg="/post-fg"
post_type_ot="/post-ot"
post_type_sb="/post-sb"
post_type_gh="/post-gh"
post_type_hym="/post-hym"
import random
post_post_count= random.randint(1,10)
temp_post_like_count= random.randint(0,((post_post_count * 2))
if post_type_fg in command_1:
print("You posted",command_1[8:],"in the section forum games")
print("Post Count:", post_post_count)
print("Like Count: (", post_like_count, "*")
else:
print("error command 1")
解决方案
问题是由上一行引起的,即:
temp_post_like_count= random.randint(0,((post_post_count * 2))
你有不平衡的括号((
超过)
)。如果您得到SyntaxError
但指出的行没有显示任何错误,那么很有可能,该问题实际上在前一行。
推荐阅读
- reinforcement-learning - Ray RLllib:供外部使用的出口政策
- r - ggplot中传说中的希腊字母
- wordpress - 如何让一个静态 HTML 文件正常访问,不让 WordPress 运行?
- c++ - 使用 boost asio 时出现“解决:找不到主机(权威)”异常
- scala - Spark:无法将此数组转换为不安全的格式,因为它太大了
- python - 通过 python 将视频上传到 youtube
- java - Libgdx 在 Fedora 31 上不起作用 - 无法初始化类 org.lwjgl.Sys
- typescript - 枚举/类型/字符串作为对象类型/接口中的键
- apache-kafka - Kafka 代理正常关闭,错误的元数据被传递到 Kafka 连接客户端
- python - 从 C++ 函数与 Python 函数返回的值不一致,用于偏正态分布