简体   繁体   English

如何将读取文本文件的结果存储为变量?

[英]How do I store the result from reading a text file as a variable?

I'm trying to read from a text document我正在尝试从文本文档中读取

text_file.readline(2)

Any ideas how I could save the result under a variable?任何想法如何将结果保存在变量下?

variable = text_file.readline(2)

也许您应该阅读基本教程:)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用文件中的文本作为变量名? - How do I use text from a file as a variable name? 如何从 GUI 检索文本框中的输入并将其存储在变量中? - How do I retrieve the input into my text box from my GUI and store it in a variable? 从文件中读取文本时,如何从 escaping 停止 Python 反斜杠? - How do I stop Python from escaping the backslashes when reading text from a file? 如何将变量存储在 function 中,以便我可以从不同的文件访问它 - How do I store a variable in a function so I can access it from a different file 读取CSV文件时如何从文本字段中删除这些符号? - How do I get rid of these symbols from the text fields when reading a CSV file? 如何存储从用户输入创建的变量并在 Python 的不同文件中使用它? - How do I store a variable that has been created from a user input and use it in a different file in Python? 从文本文件读入具有可变列的字典 - Reading from a text file into a dictionary with variable columns 如何从文本文件中读取变量作为整数,修改所述变量然后将其存储在 Python 中的同一个文本文件中? - How to read a variable from a text file as an integer, modify said variable then store it in the same text file in Python? 如何存储文本文件中的数据,然后在 tkinter 按钮中使用它? - How do I store data from a text file to then use it within a tkinter button? 如何将文本文件中的值存储到 2D Numpy 数组中? - How do i store values from a text file into a 2D Numpy array?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM