python - 我需要帮助将数据附加到文本文件中
问题描述
Temp = int(input("Temp: "))
Humid = int(input("Humidity: "))
Wind = int(input("Wind: "))
new_data = [Temp, Humid, Wind]
if Temp < 120 and Temp > 0 and Humid < 120 and Humid > 0 and Wind < 120 and Wind > 0:
with open('C:/Users/amaya/OneDrive/Desktop/CIS 2300/Test_file.txt', 'a') as f:
new_data.append(f)
print("ok will append new data")
else:
print("The numbers are to high/low.")
pass
您好,我正在尝试将“new_data”附加到 test_file 中,但不断收到此错误“AttributeError:'_io.TextIOWrapper' 对象没有属性'append'”。我在输入 f.append(new_data) 时遇到了同样的错误。 提前致谢 :)
解决方案
推荐阅读
- azure - Azure Speech to text 演示通过错误。
- python - 我想知道我应该如何填写第二个参数,以免出现 str not callable 错误
- google-chrome - Twilio Video 未在较慢的网络上发布
- wordpress - 使用 WP Rocket 破坏了我的网站 - 未能设置推荐人策略破坏了我的网站
- php - 会话在php中随机过期
- javascript - 如何创建一个可以使用 onclick 更改/恢复部分样式的按钮?
- html - 如何用正则表达式中的其他字符替换
- node.js - PM2 启动 Appname 返回错误无法在 Ubuntu 16 中找到模块
- sql - 如何在 csv 文件中使用带有空值的 csv 批量插入数据?
- postgresql - PostgresQL 错误:关系不存在
我是 Postgres 和 plpsql 的新手,如果答案很明显,我很抱歉。但是我无法弄清楚我在这里做错了什么。当我使用示例 DB 函数时,一切都很好。当我尝试创建自己的:
CREATE OR REPLACE FUNCTION get_trans (p_param VARCHAR) RETURNS TABLE ( amount money, transactionId UUID