Python语法错误:无法分配给模块中的运算符,但可以在解释器中使用 [英] Python syntax error: can't assign to operator in module but works in interpreter

查看:27
本文介绍了Python语法错误:无法分配给模块中的运算符,但可以在解释器中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串 a 我想根据它的长度将它分成两半,所以我有

I have a string a and I would like to split it in half depending on its length, so I have

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

这在解释器中工作正常,但是当我从命令行运行模块时,python 给了我一个 SyntaxError: can't assignment to operator.这可能是什么问题.

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. What could be the issue here.

推荐答案

你可能会打错连字符和下划线,试试

You might mistype hyphen and underscore, try

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

这篇关于Python语法错误:无法分配给模块中的运算符,但可以在解释器中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆