在UD功能中附加文件

发布于 2025-02-07 01:22:50 字数 345 浏览 1 评论 0原文

我刚刚定义了一个函数来附加文本文件。似乎还可以,除了执行时,要键入文本,光标从“无”开始,问题以及如何删除“无”。但是,此“无”没有附加在txt文件中 这是我的代码

def file_apend(fa,x): fa.write(x) fa.close() fa = open('whd.txt','a')x = input(print('输入文本以附加文件........'....'))

file_apend(fa,x)

out the ut ...

输入文本以附加文件....... 没有我可以在这里附加...。

简而言之,如何删除此“无”

I just defined a function to append a text file. it seems to be OK, except, at time of execution to Typing Text the Cursor starts from 'None', what the problem and how to remove the 'None'. However, this 'None' is not appended in txt file
here is my code

def file_apend(fa,x):
fa.write(x)
fa.close()
fa = open('whd.txt','a') x=input(print('Enter Text to Append in File....... '))
file_apend(fa,x)

the OUT PUT is...

Enter Text to Append in File.......
None I can append here....

In Short HOW TO REMOVE THIS 'NONE'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

来世叙缘 2025-02-14 01:22:50

我从另一个答案中得到了解决方案。这是我的解决方案:

def file_apend(fa,x):
    fa.write(x)
    fa.close()
fa = open('whd.txt','a')
(print('Enter Text to Append in File....... '))
x=input()   
file_apend(fa,x)

我在单独的行中使用了print()

I got the solution from another answer. Here is my solution:

def file_apend(fa,x):
    fa.write(x)
    fa.close()
fa = open('whd.txt','a')
(print('Enter Text to Append in File....... '))
x=input()   
file_apend(fa,x)

I used print() in a separate line.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文