python基本数据类型-Python之基本数据类型

1 classstr(object):2 """

3 str(object="") -> str4 str(bytes_or_buffer[, encoding[, errors]]) -> str5

6 Create a new string object from the given object. If encoding or7 errors is specified, then the object must expose a data buffer8 that will be decoded using the given encoding and error handler.9 Otherwise, returns the result of object.__str__() (if defined)10 or repr(object).11 encoding defaults to sys.getdefaultencoding().12 errors defaults to "strict".13 """

14 def capitalize(self): #real signature unknown; restored from __doc__

15 """

16 首字母变大写17 name = "nick is good, Today is nice day."18 a = name.capitalize()19 print(a)20 """

21 S.capitalize() ->str22

23 Return a capitalized version of S, i.e. make the first character24 have upper case andthe rest lower case.25 """

26 return ""27

28 def casefold(self): # real signature unknown; restored from __doc__29 """

30 首字母变小写31 name = "Nick is good, Today is nice day.

32 a =name.casefold()33 print(a)34 """

35 S.casefold() -> str36

37 Return a version of S suitable for caseless comparisons.38 """

39 return ""

40

41 def center(self, width, fillchar=None): #real signature unknown; restored from __doc__

42 """

43 内容居中,width:总长度;fillchar:空白处填充内容,默认无。44 name = "Nick is good, Today is nice day.45 a = name.center(60,"$")46 print(a)47 """

48 S.center(width[, fillchar]) ->str49 Return S centered in a string of length width. Padding is

50 done using the specified fill character (default isa space)51 """

52 return ""53

54 def count(self, sub, start=None, end=None): # real signature unknown; restored from __doc__55 """

56 子序列个数,0到26中n出现了几次。57 name = "nck is good, Today is nice day.

58 a = name.count("n",0,26)59 print(a)60 """

61 S.count(sub[, start[, end]]) -> int62

63 Return the number of non-overlapping occurrences of substring sub in64 string S[start:end]. Optional arguments start and end are65 interpreted as in slice notation.66 """

67 return068

69 def encode(self, encoding="utf-8", errors="strict"): #real signature unknown; restored from __doc__

70 """

71 """

72 编码,针对unicode.73 temp = "烧饼

74 temp.encode("unicode")75 """

76 S.encode(encoding="utf-8", errors="strict") -> bytes77

78 Encode S using the codec registered for encoding. Default encoding79 is "utf-8". errors may be given to set a different error80 handling scheme. Default is "strict" meaning that encoding errors raise81 a UnicodeEncodeError. Other possible values are "ignore", "replace" and82 "xmlcharrefreplace" as well as any other name registered with83 codecs.register_error that can handle UnicodeEncodeErrors.84 """

85 return b""

86

87 def endswith(self, suffix, start=None, end=None): #real signature unknown; restored from __doc__

88 """

89 """

90 是否以XX结束,0到4是否以k结尾91 name = "nck is good, Today is nice day.

92 a = name.endswith("k",0,4)93 print(a)94 """

95 S.endswith(suffix[, start[, end]]) -> bool96

97 Return True if S ends with the specified suffix, False otherwise.98 With optional start, test S beginning at that position.99 With optional end, stop comparing S at that position.100 suffix can also be a tuple of strings to try.101 """

102 returnFalse103

104 def expandtabs(self, tabsize=8): #real signature unknown; restored from __doc__

105 """

106 """

107 将tab转换成空格,默认一个tab转换成8个空格108 a =n.expandtabs()109 b = n.expandtabs(16)110 print(a)111 print(b)112 """

113 S.expandtabs(tabsize=8) -> str114

115 Return a copy of S where all tab characters are expanded using spaces.116 If tabsize is not given, a tab size of 8 characters is assumed.117 """

118 return ""

119

120 def find(self, sub, start=None, end=None): #real signature unknown; restored from __doc__

121 """

122 """

123 寻找子序列位置,如果没找到,返回 -1。124 name = "nck is good, Today is nice day."

125 a = name.find("nickk")126 print(a)127 """

128 S.find(sub[, start[, end]]) -> int129

130 Return the lowest index in S where substring sub is found,131 such that sub is contained within S[start:end]. Optional132 arguments start and end are interpreted as in slice notation.133

134 Return -1 on failure.135 """

136 return0137

138 def format(self, *args, **kwargs): #known special case of str.format

139 """

140 """

141 字符串格式化,动态参数142 name = "nck is good, Today is nice day."

143 a =name.format()144 print(a)145 """

146 S.format(*args, **kwargs) -> str147

148 Return a formatted version of S, using substitutions from args and kwargs.149 The substitutions are identified by braces ("{" and "}").150 """

151 pass

152

153 def format_map(self, mapping): #real signature unknown; restored from __doc__

154 """

155 """

156 dict = {"Foo": 54.23345}157 fmt = "Foo = {Foo:.3f}"

158 result =fmt.format_map(dict)159 print(result) #Foo = 54.233

160 """

161 S.format_map(mapping) -> str162

163 Return a formatted version of S, using substitutions from mapping.164 The substitutions are identified by braces ("{" and "}").165 """

166 return ""

167

168 def index(self, sub, start=None, end=None): #real signature unknown; restored from __doc__

169 """

170 """

171 #子序列位置,如果没有找到就报错

172 name = "nck is good, Today is nice day."

173 a = name.index("nick")174 print(a)175 """

176 S.index(sub[, start[, end]]) -> int177

178 Like S.find() but raise ValueError when the substring is not found.179 """

180 return0181

182 def isalnum(self): #real signature unknown; restored from __doc__

183 """

184 """

185 是否是字母和数字186 name = "nck is good, Today is nice day."

187 a =name.isalnum()188 print(a)189 """

190 S.isalnum() -> bool191

192 Return True if all characters in S are alphanumeric193 and there is at least one character in S, False otherwise.194 """

195 returnFalse196

197 def isalpha(self): #real signature unknown; restored from __doc__

198 """

199 """

200 是否是字母201 name = "nck is good, Today is nice day."

202 a =name.isalpha()203 print(a)204 """

205 S.isalpha() -> bool206

207 Return True if all characters in S are alphabetic208 and there is at least one character in S, False otherwise.209 """

210 returnFalse211

212 def isdecimal(self): #real signature unknown; restored from __doc__

213 """

214 检查字符串是否只包含十进制字符。这种方法只存在于unicode对象。215 """

216 S.isdecimal() ->bool217

218 Return True if there are only decimal characters inS,219 False otherwise.220 """

221 return False222

223 def isdigit(self): # real signature unknown; restored from __doc__224 """

225 """

226 是否是数字227 name = "nck is good, Today is nice day. "228 a = name.isdigit()229 print(a)230 """

231 S.isdigit() ->bool232

233 Return True if all characters inS are digits234 and there is at least one character inS, False otherwise.235 """

236 return False237

238 def isidentifier(self): # real signature unknown; restored from __doc__239 """

240 """

241 判断字符串是否可为合法的标识符242 """

243 S.isidentifier() ->bool244

245 Return True if S isa valid identifier according246 to the language definition.247

248 Use keyword.iskeyword() to test forreserved identifiers249 such as "def" and "class".250 """

251 return False252

253 def islower(self): # real signature unknown; restored from __doc__254 """

255 """

256 是否小写257 name = "nck is good, Today is nice day. "258 a = name.islower()259 print(a)260 """

261 S.islower() ->bool262

263 Return True if all cased characters in S are lowercase and there is

264 at least one cased character inS, False otherwise.265 """

266 return False267

268 def isnumeric(self): # real signature unknown; restored from __doc__269 """

270 """

271 检查是否只有数字字符组成的字符串272 name = "111111111111111”273 a = name.isnumeric()274 print(a)275 """

276 S.isnumeric() ->bool277

278 Return True if there are only numeric characters inS,279 False otherwise.280 """

281 return False282

283 def isprintable(self): # real signature unknown; restored from __doc__284 """

285 """

286 判断字符串中所有字符是否都属于可见字符287 name = "nck is good, Today is nice day. "288 a = name.isprintable()289 print(a)290 """

291 S.isprintable() ->bool292

293 Return True if all characters inS are considered294 printable in repr() or S isempty, False otherwise.295 """

296 return False297

298 def isspace(self): # real signature unknown; restored from __doc__299 """

300 """

301 字符串是否只由空格组成302 name = " "303 a = name.isspace()304 print(a)305 """

306 S.isspace() ->bool307

308 Return True if all characters inS are whitespace309 and there is at least one character inS, False otherwise.310 """

311 return False312

313 def istitle(self): # real signature unknown; restored from __doc__314 """

315 """

316 检测字符串中所有的单词拼写首字母是否为大写,且其他字母为小写317 name = "Nick, Today."318 a = name.istitle()319 print(a)320 """

321 """

322 S.istitle() -> bool323

324 Return True if S is a titlecased string and there is at least one325 character in S, i.e. upper- and titlecase characters may only326 follow uncased characters and lowercase characters only cased ones.327 Return False otherwise.328 """

329 returnFalse330

331 def isupper(self): #real signature unknown; restored from __doc__

332 """

333 """

334 检测字符串中所有的字母是否都为大写335 name = "NICK"

336 a =name.isupper()337 print(a)338 """

339 S.isupper() -> bool340

341 Return True if all cased characters in S are uppercase and there is342 at least one cased character in S, False otherwise.343 """

344 returnFalse345

346 def join(self, iterable): #real signature unknown; restored from __doc__

347 """

348 """

349 连接两个字符串350 li = ["nick","serven"]351 a = "".join(li)352 b = "_".join(li)353 print(a)354 print(b)355 """

356 S.join(iterable) -> str357

358 Return a string which is the concatenation of the strings in the359 iterable. The separator between elements is S.360 """

361 return ""

362

363 def ljust(self, width, fillchar=None): #real signature unknown; restored from __doc__

364 """

365 """

366 向左对齐,右侧填充367 name = "nck is good, Today is nice day."

368 a = name.ljust(66)369 print(a)370 """

371 S.ljust(width[, fillchar]) -> str372

373 Return S left-justified in a Unicode string of length width. Padding is374 done using the specified fill character (default is a space).375 """

376 return ""

377

378 def lower(self): #real signature unknown; restored from __doc__

379 """

380 """

381 容左对齐,右侧填充382 name = "NiNi"

383 a =name.lower()384 print(a)385 """

386 S.lower() -> str387

388 Return a copy of the string S converted to lowercase.389 """

390 return ""

391

392 def lstrip(self, chars=None): #real signature unknown; restored from __doc__

393 """

394 """ 移除左侧空白 """

395 S.lstrip([chars]) -> str396

397 Return a copy of the string S with leading whitespace removed.398 If chars is given and not None, remove characters in chars instead.399 """

400 return ""

401

402 def maketrans(self, *args, **kwargs): #real signature unknown

403 """

404 """

405 用于创建字符映射的转换表,对于接受两个参数的最简单的调用方式,第一个参数是字符串,表示需要转换的字符,第二个参数也是字符串表示转换的目标。406 from string importmaketrans407 intab = "aeiou"

408 outtab = "12345"

409 trantab =maketrans(intab, outtab)410 str = "this is string example....wow!!!";411 printstr.translate(trantab);412 """

413 Return a translation table usable for str.translate().414

415 If there is only one argument, it must be a dictionary mapping Unicode416 ordinals (integers) or characters to Unicode ordinals, strings or None.417 Character keys will be then converted to ordinals.418 If there are two arguments, they must be strings of equal length, and419 in the resulting dictionary, each character in x will be mapped to the420 character at the same position in y. If there is a third argument, it421 must be a string, whose characters will be mapped to None in the result.422 """

423 pass

424

425 def partition(self, sep): #real signature unknown; restored from __doc__

426 """

427 """

428 分割,前,中,后三部分429 name = "Nick is good, Today is nice day."

430 a = name.partition("good")431 print(a)432 """

433 S.partition(sep) -> (head, sep, tail)434

435 Search for the separator sep in S, and return the part before it,436 the separator itself, and the part after it. If the separator is not437 found, return S and two empty strings.438 """

439 pass

440

441 def replace(self, old, new, count=None): #real signature unknown; restored from __doc__

442 """

443 """

444 替换445 name = "Nick is good, Today is nice day."

446 a = name.replace("good","man")447 print(a)448 """

449 S.replace(old, new[, count]) -> str450

451 Return a copy of S with all occurrences of substring452 old replaced by new. If the optional argument count is453 given, only the first count occurrences are replaced.454 """

455 return ""

456

457 def rfind(self, sub, start=None, end=None): #real signature unknown; restored from __doc__

458 """

459 """

460 返回字符串最后一次出现的位置,如果没有匹配项则返回-1

461 """

462 S.rfind(sub[, start[, end]]) -> int463

464 Return the highest index in S where substring sub is found,465 such that sub is contained within S[start:end]. Optional466 arguments start and end are interpreted as in slice notation.467

468 Return -1 on failure.469 """

470 return0471

472 def rindex(self, sub, start=None, end=None): #real signature unknown; restored from __doc__

473 """

474 """

475 返回子字符串 str 在字符串中最后出现的位置,如果没有匹配的字符串会报异常476 """

477 S.rindex(sub[, start[, end]]) -> int478

479 Like S.rfind() but raise ValueError when the substring is not found.480 """

481 return0482

483 def rjust(self, width, fillchar=None): #real signature unknown; restored from __doc__

484 """

485 """

486 返回一个原字符串右对齐,并使用空格填充至长度 width 的新字符串。如果指定的长度小于字符串的长度则返回原字符串487 str = "this is string example....wow!!!"

488 print(str.rjust(50, "$"))489 """

490 S.rjust(width[, fillchar]) -> str491

492 Return S right-justified in a string of length width. Padding is493 done using the specified fill character (default is a space).494 """

495 return ""

496

497 def rpartition(self, sep): #real signature unknown; restored from __doc__

498 """

499 """

500 根据指定的分隔符将字符串进行分割501 """

502 S.rpartition(sep) -> (head, sep, tail)503

504 Search for the separator sep in S, starting at the end of S, and return505 the part before it, the separator itself, and the part after it. If the506 separator is not found, return two empty strings and S.507 """

508 pass

509

510 def rsplit(self, sep=None, maxsplit=-1): #real signature unknown; restored from __doc__

511 """

512 """

513 指定分隔符对字符串进行切片514 name = "Nick is good, Today is nice day."

515 a = name.rsplit("is")516 print(a)517 """

518 S.rsplit(sep=None, maxsplit=-1) -> list of strings519

520 Return a list of the words in S, using sep as the521 delimiter string, starting at the end of the string and522 working to the front. If maxsplit is given, at most maxsplit523 splits are done. If sep is not specified, any whitespace string524 is a separator.525 """

526 return[]527

528 def rstrip(self, chars=None): #real signature unknown; restored from __doc__

529 """

530 """

531 删除 string 字符串末尾的指定字符(默认为空格)532 """

533 S.rstrip([chars]) -> str534

535 Return a copy of the string S with trailing whitespace removed.536 If chars is given and not None, remove characters in chars instead.537 """

538 return ""

539

540 def split(self, sep=None, maxsplit=-1): #real signature unknown; restored from __doc__

541 """

542 """

543 通过指定分隔符对字符串进行切片544 str = "Line1-abcdef Line2-abc Line4-abcd";545 printstr.split( );546 print str.split(" ", 1);547 """

548 S.split(sep=None, maxsplit=-1) -> list of strings549

550 Return a list of the words in S, using sep as the551 delimiter string. If maxsplit is given, at most maxsplit552 splits are done. If sep is not specified or is None, any553 whitespace string is a separator and empty strings are554 removed from the result.555 """

556 return[]557

558 def splitlines(self, keepends=None): #real signature unknown; restored from __doc__

559 """

560 """

561 按照行分隔,返回一个包含各行作为元素的列表562 """

563 S.splitlines([keepends]) -> list of strings564

565 Return a list of the lines in S, breaking at line boundaries.566 Line breaks are not included in the resulting list unless keepends567 is given and true.568 """

569 return[]570

571 def startswith(self, prefix, start=None, end=None): #real signature unknown; restored from __doc__

572 """

573 """

574 检查字符串是否是以指定子字符串开头,如果是则返回 True,否则返回 False575 """

576 S.startswith(prefix[, start[, end]]) -> bool577

578 Return True if S starts with the specified prefix, False otherwise.579 With optional start, test S beginning at that position.580 With optional end, stop comparing S at that position.581 prefix can also be a tuple of strings to try.582 """

583 returnFalse584

585 def strip(self, chars=None): #real signature unknown; restored from __doc__

586 """

587 """

588 用于移除字符串头尾指定的字符(默认为空格).589 """

590 S.strip([chars]) -> str591

592 Return a copy of the string S with leading and trailing593 whitespace removed.594 If chars is given and not None, remove characters in chars instead.595 """

596 return ""

597

598 def swapcase(self): #real signature unknown; restored from __doc__

599 """

600 """

601 用于对字符串的大小写字母进行转换602 """

603 S.swapcase() -> str604

605 Return a copy of S with uppercase characters converted to lowercase606 and vice versa.607 """

608 return ""

609

610 def title(self): #real signature unknown; restored from __doc__

611 """

612 S.title() -> str613

614 Return a titlecased version of S, i.e. words start with title case615 characters, all remaining cased characters have lower case.616 """

617 return ""

618

619 def translate(self, table): #real signature unknown; restored from __doc__

620 """

621 S.translate(table) -> str622

623 Return a copy of the string S in which each character has been mapped624 through the given translation table. The table must implement625 lookup/indexing via __getitem__, for instance a dictionary or list,626 mapping Unicode ordinals to Unicode ordinals, strings, or None. If627 this operation raises LookupError, the character is left untouched.628 Characters mapped to None are deleted.629 """

630 return ""

631

632 def upper(self): #real signature unknown; restored from __doc__

633 """

634 """

635 将字符串中的小写字母转为大写字母636 """

637 S.upper() -> str638

639 Return a copy of S converted to uppercase.640 """

641 return ""

642

643 def zfill(self, width): #real signature unknown; restored from __doc__

644 """

645 """

646 返回指定长度的字符串,原字符串右对齐,前面填充0647 """

648 S.zfill(width) -> str649

650 Pad a numeric string S with zeros on the left, to fill a field651 of the specified width. The string S is never truncated.652 """

653 return ""

654

655 def __add__(self, *args, **kwargs): #real signature unknown

656 """Return self+value."""

657 pass

658

659 def __contains__(self, *args, **kwargs): #real signature unknown

660 """Return key in self."""

661 pass

662

663 def __eq__(self, *args, **kwargs): #real signature unknown

664 """Return self==value."""

665 pass

666

667 def __format__(self, format_spec): #real signature unknown; restored from __doc__

668 """

669 S.__format__(format_spec) -> str670

671 Return a formatted version of S as described by format_spec.672 """

673 return ""

674

675 def __getattribute__(self, *args, **kwargs): #real signature unknown

676 """Return getattr(self, name)."""

677 pass

678

679 def __getitem__(self, *args, **kwargs): #real signature unknown

680 """Return self[key]."""

681 pass

682

683 def __getnewargs__(self, *args, **kwargs): #real signature unknown

684 pass

685

686 def __ge__(self, *args, **kwargs): #real signature unknown

687 """Return self>=value."""

688 pass

689

690 def __gt__(self, *args, **kwargs): #real signature unknown

691 """Return self>value."""

692 pass

693

694 def __hash__(self, *args, **kwargs): #real signature unknown

695 """Return hash(self)."""

696 pass

697

698 def __init__(self, value="", encoding=None, errors="strict"): #known special case of str.__init__

699 """

700 str(object="") -> str701 str(bytes_or_buffer[, encoding[, errors]]) -> str702

703 Create a new string object from the given object. If encoding or704 errors is specified, then the object must expose a data buffer705 that will be decoded using the given encoding and error handler.706 Otherwise, returns the result of object.__str__() (if defined)707 or repr(object).708 encoding defaults to sys.getdefaultencoding().709 errors defaults to "strict".710 # (copied from class doc)711 """

712 pass

713

714 def __iter__(self, *args, **kwargs): #real signature unknown

715 """Implement iter(self)."""

716 pass

717

718 def __len__(self, *args, **kwargs): #real signature unknown

719 """Return len(self)."""

720 pass

721

722 def __le__(self, *args, **kwargs): #real signature unknown

723 """Return self<=value."""

724 pass

725

726 def __lt__(self, *args, **kwargs): #real signature unknown

727 """Return self

728 pass

729

730 def __mod__(self, *args, **kwargs): #real signature unknown

731 """Return self%value."""

732 pass

733

734 def __mul__(self, *args, **kwargs): #real signature unknown

735 """Return self*value.n"""

736 pass

737

738 @staticmethod #known case of __new__

739 def __new__(*args, **kwargs): #real signature unknown

740 """Create and return a new object. See help(type) for accurate signature."""

741 pass

742

743 def __ne__(self, *args, **kwargs): #real signature unknown

744 """Return self!=value."""

745 pass

746

747 def __repr__(self, *args, **kwargs): #real signature unknown

748 """Return repr(self)."""

749 pass

750

751 def __rmod__(self, *args, **kwargs): #real signature unknown

752 """Return value%self."""

753 pass

754

755 def __rmul__(self, *args, **kwargs): #real signature unknown

756 """Return self*value."""

757 pass

758

759 def __sizeof__(self): #real signature unknown; restored from __doc__

760 """S.__sizeof__() -> size of S in memory, in bytes"""

761 pass

762

763 def __str__(self, *args, **kwargs): #real signature unknown

764 """Return str(self)."""

765 pass

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值