For the code below, its runs fine when I substitute "[email protected]" with "fuchida". If I use the email format for directory name I get the following error "WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect:" . Please let me know what I can do to get this to work, my money is on the "@" symbol fudging things up but I do not know how to resolve it in python so far.
import os
def dirListing():
dirList = os.listdir("C:\\Program Files\home\Server\Logs\[email protected]")
for fname in dirList:
print fname
return
def main():
dirListing()
if __name__ == '__main__':main()
Escape sequences allow you to include special characters in strings. To do this, simply add a backslash ( \ ) before the character you want to escape.
To insert characters that are illegal in a string, use an escape character. An escape character is a backslash \ followed by the character you want to insert.
You can't have hyphens in variable names in python. That's the subtraction operator. Consider using an underscore instead: education_numType = ...
I suspect problems with your \
as escape characters. Try this:
import os
def dirListing():
dirList = os.listdir(r"C:\\Program Files\home\Server\Logs\[email protected]")
for fname in dirList:
print fname
return
def main():
dirListing()
if __name__ == '__main__':main()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With