Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下形式的数据
str = '"A,B,C,Be,F,Sa,Su"' # where str[1]='M' and str[2]=','
我想找到if "mystring" in str:。其中 mystring 是 M、T、W 或 Th 等等。
if "mystring" in str:
但是,我只想要特定的字符串。即if "S" in str:输出应该是无。并且if "B" in str:应该只是“B”而不是“Be”
if "S" in str:
if "B" in str:
>>> text = '"A,B,C,Be,F,Sa,Su"' >>> 'A' in text.strip('"').split(',') True >>> 'S' in text.strip('"').split(',') False