python 函数的参数无法使用和一个打印错误

python function's parameter could not use and one print error

def readswitch(x,y,connn,read):
    x='create vlan'
    y='global'
    conn = sqlite3.connect('server.db')
    if conn:
        cur = conn.cursor()
        run= cur.execute("SELECT command FROM switch WHERE   function =? or type = ?  ORDER BY key ASC",(x,y))
        read = cur.fetchall()
        return run;

import database
print (database.readswitch(x,y))

我正在尝试访问数据库和其中的 return 命令 我制作了一个名为数据库的模块无法像

一样打印它
Traceback (most recent call last):
  File "C:/Users/tommy/PycharmProjects/2015122/database.py", line 400, in <module>
    import database
  File "C:\Users\tommy\PycharmProjects15122\database.py", line 401, in <module>
    print (database.readswitch(x,y))
NameError: name 'x' is not defined

而且我的函数参数不能像

那样使用
def readswitch(x,y,connn,read):

PEP 8: missing whitespace after ',' Parameter 'y' value is not used

如何解决这个错误? 我不擅长python,这几个小时我需要帮助。谢谢!

你用参数 x,y 定义了一个函数,然后你在一个函数中重新分配它们。这没有意义,因为它们不是全局变量也不是可变的。

我建议您从函数定义中删除 x,y 或将对它们的赋值移动到全局范围(函数外部)。