简体   繁体   中英

word count error in Python using Anaconda Jupyter

I am trying to count words using the Python script below.

import os
os.chdir('D:\ECP\TAT')
filename = 'D:\ECP\TAT\Test.txt'
numlines = 0


with open (filename,'r') as file:
    for l in file:
        Wordlist = l.split()
        numlines+=1

print("Wordlist")

But I am getting the error:

FileNotFoundError: [Errno 2] No such file or directory: 'D:\\ECP\\TAT\\Test.txt'

IDE : Anaconda (Jupyter) python : 3.6
import os
os.chdir('D:\\ECP\\TAT\\')
filename = 'D:\\ECP\\TAT\\Test.txt'
numlines = 0

with open (filename,'r') as file:
    for l in file:
        Wordlist = l.split()
        numlines+=1

print(Wordlist)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM