问题描述:

So I want to make a variable from the contents of a text file.

E.g

The text file contains the sentence "Ask not what your country can do for you ask what you can do for your country"

Now I want the variable to be like

Sentence = ("Ask not what your country can do for you ask what you can do for your country")

But from the text file, if that makes any sense?

网友答案:

The file contains.

[email protected] ~/Projects/Stackoverflow $ cat abc.txt 
hai am here

Here is the python code.It's very simple logic.

fo = open("abc.txt", "r+")
a = fo.read()
相关阅读:
Top