UnboundLocalError: cannot access local variable 'review_temp' where it is not associated with a value
时间: 2024-05-20 08:17:48 浏览: 26
This error occurs when you try to access a local variable that has not been assigned a value in the current function or scope. In other words, you are trying to use a variable before it has been initialized.
To fix this error, you need to make sure that the variable is assigned a value before you try to access it. This can be done by initializing the variable with a default value or by assigning a value to it elsewhere in the code.
For example, if you have a function that uses a local variable called review_temp, you could initialize it with a default value like this:
def my_function():
review_temp = None
# rest of the code
Alternatively, you could assign a value to review_temp before using it in the function:
def my_function():
review_temp = get_review()
# rest of the code
In either case, you are ensuring that review_temp has a value associated with it before you try to use it in the function.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)