Skip to content

Instantly share code, notes, and snippets.

@cosven
Last active July 10, 2016 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosven/9e11707a8ebe98bc95948167a0001449 to your computer and use it in GitHub Desktop.
Save cosven/9e11707a8ebe98bc95948167a0001449 to your computer and use it in GitHub Desktop.
Python3 字符串比较,很奇怪。
In [33]: os.listdir('.')
Out[33]:
['.DS_Store',
'Closer - Travis.mp3',
'I Really Like You - Carly Rae Jepsen.mp3',
'Love Story - Taylor Swift.mp3',
'Per dimenticare - Zero Assoluto.mp3',
"Sono Bugiarda (I'm A Believer) - Caterina Caselli.mp3",
'The Phoenix - Fall Out Boy.mp3',
'We Are Never Ever Getting Back Together - Taylor Swift.mp3',
'You Got Me - Colbie Caillat.mp3',
'ガーネット - 奥華子.mp3',
'ブルーバード - いきものがかり.mp3',
'初恋 - 奥華子.mp3',
'思念是一种病(Live) - live - 张震岳.mp3',
'最后一班车 - 刺猬.mp3',
'梁山伯与祝英台 - 群星.mp3']
In [34]: a = os.listdir('.')[-5]
In [35]: a
Out[35]: 'ブルーバード - いきものがかり.mp3'
In [36]: b = 'ブルーバード - いきものがかり.mp3' # 用鼠标复制这个字符串
In [37]: a == b # 这里很奇怪,明明是这样复制下来的,却不相等
Out[37]: False
In [38]: current_path = os.getcwd()
In [39]: b_path = os.path.join(current_path, b)
In [40]: os.path.exists(b_path) # 这里也很奇怪,既然上面 a 和 b 不相等,这里路径又存在。搞不懂?
Out[40]: True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment