简体   繁体   English

Python语法错误:无法在模块中分配给运算符但在解释器中工作

[英]Python syntax error: can't assign to operator in module but works in interpreter

I have a string a and I would like to split it in half depending on its length, so I have 我有一个字符串a ,我想根据它的长度将它分成两半,所以我有

a-front = len(a) / 2 + len(a) % 2

this works fine in the interpreter but when i run the module from the command line python gives me a SyntaxError: can't assign to operator . 这在解释器中运行正常,但是当我从命令行运行模块时,python给了我一个SyntaxError: can't assign to operator What could be the issue here. 这可能是什么问题。

您可能会错误地输入连字符和下划线,请尝试

a_front = len(a) / 2 + len(a) % 2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM