python - 语法错误代码之前有效,但现在无效
问题描述
我有一个错误,它之前工作过,但现在它没有,有什么提示吗?
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
解决方案
抱歉没有说清楚我想要什么!我想要的是代码可以正常工作,当前错误位于 varpir 变量行,我尝试这样做,但这只是给出了另一个错误,错误:ValueError:int() 以 10 为底的无效文字:
编辑:文件数据被刷新,所以它是空的,导致它崩溃,这实际上是解决方案,不过谢谢
varpir = int(cant)
varpir = varpir + int(1)``` ''
推荐阅读
- reactjs - 如何构建供 HTML 应用程序使用的 React 组件?
- sql - 按年份和比例排列数据
- c# - 样板上的 CA1304
- django - Django - @login_required 装饰器,同时使用表单 POST 传递参数
- angular - Is there a way to use background colors instead of primary for some components using material dark theme?
- json - 如何将一个值与前一个对象进行比较?
- c++ - C++ 定义/赋值语法
- android-studio - 我是 Flutter 新手,在运行我的第一个应用程序时遇到了错误
- android - 在 Jetpack @Compose 函数中使用 LiveData 作为状态
- python - 在 anaconda 中安装 talib