with open("dictionary.txt") as f: # Open the file and save it as "f"
dictionary = f.read() # Read the content of the file and save it to "dictionary"
如果您想从网站上阅读,请尝试以下方法:
import urllib2
dictionary = urllib2.urlopen("http://www.mieliestronk.com/corncob_lowercase.txt").read() # Open the website from the url and save its contents to "dictionary"
我想你应该看看这个你想做什么(http://www.pythonforbeginners.com/files/reading-and-writing-files-in-python)
这应该是有帮助的
你所要做的就是:
如果您想从网站上阅读,请尝试以下方法:
您可能应该参考web上的一些代码示例来读取文件。你需要这样的东西:
相关问题 更多 >
编程相关推荐