日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python中str和int区别_Python中的string方法和str方法有什么区别?

發布時間:2025/3/20 python 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python中str和int区别_Python中的string方法和str方法有什么区别? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

String是一個模塊,str是一個類型。

我發現str有方法,有些str的方法與string相同。在>>>dir(str)

['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__',

'__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__',

'__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__',

'__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',

'__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__',

'__subclasshook__', '_formatter_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', 'upper',

'zfill']

>>> dir(string)

['Formatter', 'Template', '_TemplateMetaclass', '__builtins__', '__doc__',

'__file__', '__name__', '__package__', '_float', '_idmap', '_idmapL', '_int',

'_long', '_multimap', '_re', 'ascii_letters', 'ascii_lowercase', 'ascii_uppercase',

'atof', 'atof_error', 'atoi', 'atoi_error', 'atol', 'atol_error', 'capitalize',

'capwords', 'center', 'count', 'digits', 'expandtabs', 'find', 'hexdigits', 'index',

'index_error', 'join', 'joinfields', 'letters', 'ljust', 'lower', 'lowercase',

'lstrip', 'maketrans', 'octdigits', 'printable', 'punctuation', 'replace', 'rfind',

'rindex', 'rjust', 'rsplit', 'rstrip', 'split', 'splitfields', 'strip', 'swapcase',

'translate', 'upper', 'uppercase', 'whitespace', 'zfill']

這兩套方法有什么區別?

str或string可以使用彼此的方法嗎?在

總結

以上是生活随笔為你收集整理的python中str和int区别_Python中的string方法和str方法有什么区别?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。