首页 > 解决方案 > 语法错误代码之前有效,但现在无效

问题描述

我有一个错误,它之前工作过,但现在它没有,有什么提示吗?

SyntaxError: cannot assign to function call 这是错误,我知道它的位置,我真的不知道为什么它 like.from io import open_code import time

    

def count1():
    for xa in range(1,900000000000000000000000000000000000000000): # loop

        time.sleep(1) 

        with open('door4.txt','w') as f1: # file (think of it as number 1)

            f1.write(str(xa)) # writes the number into the file door 4

            with open('door5.txt','r') as f2: # another file, 
#this one gets saved to the file, the other part (above)is only there for throughout the session
                cant = f2.read() # becomes the saved string value '1'

                varpir = int(cant) = int(cant) + 1 #here is the issue it says the error
#if you delete a few lines then it works but not how I want it to work





                with open('door5.txt', "w") as f3: #same file above but with write priveleges
                    f3.write(str(varpir)) # writes the code
                    print(xa) # prints the code of door4
                    print(varpir) # prints the code of door5
        






def all():
    count1() 



all() # the line that runs it all

标签: pythonsyntax

解决方案


抱歉没有说清楚我想要什么!我想要的是代码可以正常工作,当前错误位于 varpir 变量行,我尝试这样做,但这只是给出了另一个错误,错误:ValueError:int() 以 10 为底的无效文字:

编辑:文件数据被刷新,所以它是空的,导致它崩溃,这实际上是解决方案,不过谢谢


                varpir  = int(cant)
                varpir = varpir + int(1)```   ''


推荐阅读