Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
781 views
in Technique[技术] by (71.8m points)

heroku - How do i force ignore case sensitivity on Pythons os.path.exist function?

On windows, os.path.exists returns true, no matter if the case of the argument matches the file name. However, on my Heroku deployed app, which runs on Unix, this is not the case - it returns False when a user for some reason uses upper case letters in the argument. I could work around this by having all files always in lowercase, and putting a .lower() after the user input, but this is not the nicest way i feel. How can i ensure that when os.path.exists compares input with files, it absolutely ignores case on the files? Lets say i get all files with os.listdir and then iterate over the list, converting them all to lowercase and then matching the user input with that list. I want to do exactly that, but without having to do these extra steps, but with just using os.path.exist() - is that possible?

question from:https://stackoverflow.com/questions/66049640/how-do-i-force-ignore-case-sensitivity-on-pythons-os-path-exist-function

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...