发电机数据库项目未被识别



我得到了名字,不明白为什么

这是我的代码:

import boto3, time, datetime
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Wishlist')
device = input('What is the Item being requested?n')
device = device.upper()
aliasInput = input('What is the Alias of the user?n')
aliasInput = aliasInput.upper()

table.put_item(
    Item={
        'Device': device,
        'Date': Date.now(),
        'Alias': aliasInput
    }
)

我的桌子主键是"设备",排序键是" date",我在调试中得到了此键

Traceback (most recent call last):
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py",        line 1683, in <module>
    main()
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1677, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1087, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"n", file, 'exec'), glob, loc)
  File "/Users/gomcrai/PycharmProjects/untitled/venv/Input", line 16, in <module>
    'Date': Date.now(),
NameError: name 'Date' is not defined
Process finished with exit code 1

系统不喜欢您对Date.now()的调用。您尚未为您的Date.now()命令完成适当的import。您需要导入您认为命令来自的模块。

也许您打算打字:

import datetime
    :
    :
    'Date': datetime.datetime.now(),

    'Date': datetime.date.today(),

有很多日期和时间选项,所以我不确定您要使用哪一个。

最新更新