如何在文件中存储Python代码 [英] How to stock a Python code in a file
问题描述
我希望能够存储我在file.txt中输入的代码,这样我就可以在不同的python程序中读取/使用它。我只需要知道程序,任何代码都会作为例子,谢谢!问题是,我必须能够在file.txt中询问我想要存货的内容。
我尝试了什么: < br $>
我试图创建一个文本文件,但我不知道如何让python输入任何东西。我知道如何使用read()和readlines()和东西创建和导入文本,但如果我必须要求python输入特定的东西,我不能在文本文件中这样做,因为我需要使用python文件来做到这一点。
我想:没有想要这样的词。
但是,如果您想要要求您的用户输入详细信息,那么您需要输入
语句。请参阅 7。输入和输出 - Python 3.4.8文档 [ ^ ]和 2。内置函数 - Python 3.4.8文档 [ ^ ]。
I wanna be able to stock a code that im entering in a file.txt so i can read/use it in a different python program. I just need to know the procedure, any code will do as an exemple, thanks! the thing is that i must be able to ask for what i want to stock in the file.txt
What I have tried:
I tried to create a text file but i dont know how to ask python to enter anything. I know how to create and import a text with read() and readlines() and stuff but if i have to ask python to enter something specific, i cant do that in text file since i need to use a python file to do that.
"I wanna": There is no such word as "wanna".
However, if you want to ask your user to enter the details then you need theinput
statement. See 7. Input and Output — Python 3.4.8 documentation[^] and 2. Built-in Functions — Python 3.4.8 documentation[^].
这篇关于如何在文件中存储Python代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!