python-3.x - 上传到 Firestore 会丢失数字的准确性
问题描述
我目前在 Firestore 中有一个数据库,用于将 Discord 用户 ID 与 discord.py 一起存储。我上传它们并在控制台上显示为“数字”类型,我的文档标题是我的用户 ID。然后我还有一个字段是“watcher_id”,这也是我的用户 ID(它们是从同一个变量上传的),但它不正确。该数字丢失了最后 2-3 个值,因此如果我的 id 是671546797994541087
它,它将存储为671546797994541000
. 这是我上传数据的代码:
caller_id = ctx.message.author.id
doc_ref = db.collection('watcher_list').document(str(caller_id))
doc = doc_ref.get()
if doc.exists:
doc_data = doc.to_dict()
uuids_to_watch = doc_data['uuids_to_watch']
if not uuid in uuids_to_watch:
uuids_to_watch.append(uuid)
doc_ref.update({'watcher_id': caller_id, 'watcher': str(ctx.message.author), 'uuids_to_watch': uuids_to_watch})
else:
doc_ref.set({'watcher_id': caller_id, 'watcher': str(ctx.message.author), 'uuids_to_watch': [uuid]})
我似乎无法找出导致这种准确性损失的原因,并且想知道它是什么以及如何修复(或在最坏的情况下绕过)它。
提前致谢!
解决方案
推荐阅读
- charts - 带有聚合数据点的折线图仪表板
- scala - Scala:关于将 HList 转换为 List 的无形问题
- git - 更新 git superproject 的正确方法
- javascript - 访问唯一的嵌套 JSON 数组项
- java - Moving marker to user location in Android studio
- excel - 如何操作单元格中的字符串
- applescript - 为什么有时通过 AppleScript 激活打开的应用程序需要这么长时间(约 10 秒)?
- python - Create a Geotiff file from scattered data in python
- solidity - 我可以将我的自定义 ERC-20 与我的智能合约一起使用吗?
- android - Android 数据绑定和 LiveData:无法绑定到 LiveData 属性中的值