#if using windows filepath maybe C:\User\username\Documents
#if using mac filepath maybe /Users/username/Documents/
filepath = r'whole_path_to_file\x.1.1.1.1.1.txt'
o = open(filepath, 'r')
r = o.readlines()
print(r)
#output of example file nameed x.1.1.1.1.1.txt
['File content to read']
只要提供的路径正确,文件所在的位置并不重要。在
在下面的例子中,我自己在变量中指定文件的路径。示例文本文件位于my documents文件夹中。该文件的内容是一行文本示例。在
尝试:
希望有帮助。在
相关问题 更多 >
编程相关推荐