我刚开始用python学习编程。当我学习是否要列出我写的所有字符串模块时:
import string
print dir(string)
结果:
['Formatter','Template','_ TemplateMetaclass',' builtins ', ' doc ','文件','名称','包','_ fllo','_ ifmap ”, '_idmapL','_ int','_ long','_ multimap','_是','ascii_letters', 'ascii_lowercase','ascii_uppercase','atof','atof_error','ati', 'atoi_error','atol','atol_error','大写','capwords', 'center','count','digits','expandtabs','find','hexdigits', 'index','index_error','join','joinfields','letters','ljust', 'lower','lowercase','lstrip','maketrans','octdigits','printable', '标点符号','替换','rfind','rindex','rjust','rsplit', 'rstrip','split','splitfields','strip','swapcase','translate', 'upper','uppercase','whitespace','zfill']
但是这是怎么回事:
someString = "someValues"
print dir(someString)
结果:
['添加','类','包含',' delattr ','文档”, ' eq ','格式',' ge ',' getattribute ',' getitem < /强>”, ' getnewargs ',' getslice ',' gt ','哈希',' init < /强>”, ' le ',' len ',' LT ',' mod ',' mul < / strong>',' ne ', ' new ',' reduce ',' reduce_ex ',' repr ',' rmod < /强>”, ' rmul ',' setattr ',' sizeof ',' str ', '子类隐藏','_ formatt_field_name_split', '_formatter_parser','capitalize','center','count','decode', 'encode','endswith','expandtabs','find','format','index', 'isalnum','isalpha','isdigit','islower','isspace','istitle', 'isupper','join','ljust','lower','lstrip','partition','replace', 'rfind','rindex','rjust','rpartition','rsplit','rstrip','split', 'splitlines','startswith','strip','swapcase','title','translate', '上','zfill']
为什么结果不同?