pymysql.connect(autocommit=True)在python3.11的环境下提示:Python versions 3.5 do not allow keyword arguments after " expression
时间: 2024-04-14 18:25:42 浏览: 104
I apologize for the confusion. It seems that the error you encountered is not related to the `autocommit` parameter specifically, but rather a syntax error related to keyword arguments in general.
In Python versions prior to 3.8, keyword arguments must be passed after any positional arguments. However, starting from Python 3.8, you can mix keyword arguments and positional arguments freely.
To resolve this issue in Python 3.5, you should either upgrade to a newer version of Python or modify your code to pass the `autocommit` parameter as a positional argument instead of a keyword argument.
Here's an example of how you can modify the code to work with Python 3.5:
```python
import pymysql
# Create database connection
connection = pymysql.connect(
'your_host',
'your_user',
'your_password',
'your_database',
autocommit=True
)
# Rest of the code...
```
By passing the arguments as positional arguments instead of keyword arguments, you should be able to avoid the syntax error in Python 3.5.
阅读全文