天天看點

python中的real_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 S.capitalize() -> str18

19 Return a capitalized version of S, i.e. make the first character20 have upper case and the rest lower case.21 """

22 return ""

23

24 def casefold(self): #real signature unknown; restored from __doc__

25 """所有字元小寫(比更加牛能把很多未知的對應變小寫)"""

26 """

27 S.casefold() -> str28

29 Return a version of S suitable for caseless comparisons.30 """

31 return ""

32

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

34 """字元居中; width:總長度 ; fillchar:空白處填内容 預設無"""

35 """

36 S.center(width[, fillchar]) -> str37

38 Return S centered in a string of length width. Padding is39 done using the specified fill character (default is a space)40 """

41 return ""

42

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

44 """計算出字元串sub參數在出現幾次, start:起始位置;end:結束位置"""

45 """

46 S.count(sub[, start[, end]]) -> int47

48 Return the number of non-overlapping occurrences of substring sub in49 string S[start:end]. Optional arguments start and end are50 interpreted as in slice notation.51 """

52 return053

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

55 """判斷是否以suffix參數結尾 start:起始位置;end結束位置"""

56 """

57 S.endswith(suffix[, start[, end]]) -> bool58

59 Return True if S ends with the specified suffix, False otherwise.60 With optional start, test S beginning at that position.61 With optional end, stop comparing S at that position.62 suffix can also be a tuple of strings to try.63 """

64 returnFalse65

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

67 """以tabsize參數分割字元串,遇到'\t'不足的用空格補齊"""

68 """

69 S.expandtabs(tabsize=8) -> str70

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

74 return ""

75

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

77 """尋找子序列,找到第一個傳回位置,找不到傳回-1"""

78 """

79 S.find(sub[, start[, end]]) -> int80

81 Return the lowest index in S where substring sub is found,82 such that sub is contained within S[start:end]. Optional83 arguments start and end are interpreted as in slice notation.84

85 Return -1 on failure.86 """

87 return088

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

90 """字元串插入,動态參數,第一個參數清單形式,第二個傳入字典"""

91 """

92 S.format(*args, **kwargs) -> str93

94 Return a formatted version of S, using substitutions from args and kwargs.95 The substitutions are identified by braces ('{' and '}').96 """

97 pass

98

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

100 """傳入格式為字典形式的"""

101 """

102 S.format_map(mapping) -> str103

104 Return a formatted version of S, using substitutions from mapping.105 The substitutions are identified by braces ('{' and '}').106 """

107 return ""

108

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

110 """和find一樣尋找子序列位置,但沒找到會報錯,"""

111 """

112 S.index(sub[, start[, end]]) -> int113

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

116 return0117

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

119 """判斷是否隻有數字和字元 是傳回true,否則傳回false"""

120 """

121 S.isalnum() -> bool122

123 Return True if all characters in S are alphanumeric124 and there is at least one character in S, False otherwise.125 """

126 returnFalse127

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

129 """判斷是否隻有字元 是傳回true,否則傳回false"""

130 """

131 S.isalpha() -> bool132

133 Return True if all characters in S are alphabetic134 and there is at least one character in S, False otherwise.135 """

136 returnFalse137

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

139 """判斷是否是數字(實際中用的更多) 是傳回true,否則傳回false"""

140 """

141 S.isdecimal() -> bool142

143 Return True if there are only decimal characters in S,144 False otherwise.145 """

146 returnFalse147

148 def isdigit(self): #real signature unknown; restored from __doc__

149 """判斷是否是數字(比上面支援的種類多,不支援中文如二) 是傳回true,否則傳回false"""

150 """

151 S.isdigit() -> bool152

153 Return True if all characters in S are digits154 and there is at least one character in S, False otherwise.155 """

156 returnFalse157

158 def isidentifier(self): #real signature unknown; restored from __doc__

159 """是否符合變量的書寫方式"""

160 """

161 S.isidentifier() -> bool162

163 Return True if S is a valid identifier according164 to the language definition.165

166 Use keyword.iskeyword() to test for reserved identifiers167 such as "def" and "class".168 """

169 returnFalse170

171 def islower(self): #real signature unknown; restored from __doc__

172 """判斷字母是否全是小寫"""

173 """

174 S.islower() -> bool175

176 Return True if all cased characters in S are lowercase and there is177 at least one cased character in S, False otherwise.178 """

179 returnFalse180

181 def isnumeric(self): #real signature unknown; restored from __doc__

182 """判斷是否是數字(支援更多如中文) 是傳回true,否則傳回false"""

183 """

184 S.isnumeric() -> bool185

186 Return True if there are only numeric characters in S,187 False otherwise.188 """

189 returnFalse190

191 def isprintable(self): #real signature unknown; restored from __doc__

192 """是否有不可顯示的字元串如'\t','\n'"""

193 """

194 S.isprintable() -> bool195

196 Return True if all characters in S are considered197 printable in repr() or S is empty, False otherwise.198 """

199 returnFalse200

201 def isspace(self): #real signature unknown; restored from __doc__

202 """是否全是空格"""

203 """

204 S.isspace() -> bool205

206 Return True if all characters in S are whitespace207 and there is at least one character in S, False otherwise.208 """

209 returnFalse210

211 def istitle(self): #real signature unknown; restored from __doc__

212 """是否是标題形式的如 The Book (首字母大寫)"""

213 """

214 S.istitle() -> bool215

216 Return True if S is a titlecased string and there is at least one217 character in S, i.e. upper- and titlecase characters may only218 follow uncased characters and lowercase characters only cased ones.219 Return False otherwise.220 """

221 returnFalse222

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

224 """判斷字母是否全部是大寫"""

225 """

226 S.isupper() -> bool227

228 Return True if all cased characters in S are uppercase and there is229 at least one cased character in S, False otherwise.230 """

231 returnFalse232

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

234 """将iterable參數中的每個元素按照指定分隔符(調用join的變量)進行拼接"""

235 """

236 S.join(iterable) -> str237

238 Return a string which is the concatenation of the strings in the239 iterable. The separator between elements is S.240 """

241 return ""

242

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

244 """将字元串放在左邊,用法和center一樣"""

245 """

246 S.ljust(width[, fillchar]) -> str247

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

251 return ""

252

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

254 """将字元串轉換成小寫"""

255 """

256 S.lower() -> str257

258 Return a copy of the string S converted to lowercase.259 """

260 return ""

261

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

263 """去除左邊開始chars參數所代表的字元串(包括其子字元串可自由組合),沒有不去除,不填預設去除多餘空格還有('\t','\]n');"""

264 """

265 S.lstrip([chars]) -> str266

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

270 return ""

271

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

273 """做一個對應關系 如maketrans("abcd','1234') 将'abcvd','1234'一一對應傳回,274 調用translate時用到 用後面的替換前面的"""

275 """

276 Return a translation table usable for str.translate().277

278 If there is only one argument, it must be a dictionary mapping Unicode279 ordinals (integers) or characters to Unicode ordinals, strings or None.280 Character keys will be then converted to ordinals.281 If there are two arguments, they must be strings of equal length, and282 in the resulting dictionary, each character in x will be mapped to the283 character at the same position in y. If there is a third argument, it284 must be a string, whose characters will be mapped to None in the result.285 """

286 pass

287

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

289 """從左邊開始找到sep參數相同的字元串開始分割,('xx','sep','xx')"""

290 """

291 S.partition(sep) -> (head, sep, tail)292

293 Search for the separator sep in S, and return the part before it,294 the separator itself, and the part after it. If the separator is not295 found, return S and two empty strings.296 """

297 pass

298

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

300 """用新的代替老的字元串"""

301 """

302 S.replace(old, new[, count]) -> str303

304 Return a copy of S with all occurrences of substring305 old replaced by new. If the optional argument count is306 given, only the first count occurrences are replaced.307 """

308 return ""

309

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

311 """和find一樣,但是從右邊開始尋找"""

312 """

313 S.rfind(sub[, start[, end]]) -> int314

315 Return the highest index in S where substring sub is found,316 such that sub is contained within S[start:end]. Optional317 arguments start and end are interpreted as in slice notation.318

319 Return -1 on failure.320 """

321 return0322

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

324 """和index一樣, 但是從右邊開始尋找"""

325 """

326 S.rindex(sub[, start[, end]]) -> int327

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

330 return0331

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

333 """将字元串放在右邊,用法和center一樣"""

334 """

335 S.rjust(width[, fillchar]) -> str336

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

340 return ""

341

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

343 """從右邊開始找到sep參數相同的字元串開始分割,('xx','sep','xx')"""

344 """

345 S.rpartition(sep) -> (head, sep, tail)346

347 Search for the separator sep in S, starting at the end of S, and return348 the part before it, the separator itself, and the part after it. If the349 separator is not found, return two empty strings and S.350 """

351 pass

352

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

354 """從右邊開始找到sep參數相同的字元串開始分割,分割時去掉sep;maxsplit:代表找幾次;('xx','xx')"""

355 """

356 S.rsplit(sep=None, maxsplit=-1) -> list of strings357

358 Return a list of the words in S, using sep as the359 delimiter string, starting at the end of the string and360 working to the front. If maxsplit is given, at most maxsplit361 splits are done. If sep is not specified, any whitespace string362 is a separator.363 """

364 return[]365

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

367 """去除右邊開始chars參數所代表的字元串(包括其子字元串可自由組合),沒有不去除(隻有前一個去了後面才能去),368 不填預設去除多餘空格還有('\t','\]n');"""

369 """

370 S.rstrip([chars]) -> str371

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

375 return ""

376

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

378 """從左邊開始找到sep參數相同的字元串開始分割,分割時去掉sep;maxsplit:代表找幾次;('xx','xx')"""

379 """

380 S.split(sep=None, maxsplit=-1) -> list of strings381

382 Return a list of the words in S, using sep as the383 delimiter string. If maxsplit is given, at most maxsplit384 splits are done. If sep is not specified or is None, any385 whitespace string is a separator and empty strings are386 removed from the result.387 """

388 return[]389

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

391 """分割,按照'\n'分割,keepends:true保留換行符,false不保留換行符"""

392 """

393 S.splitlines([keepends]) -> list of strings394

395 Return a list of the lines in S, breaking at line boundaries.396 Line breaks are not included in the resulting list unless keepends397 is given and true.398 """

399 return[]400

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

402 """判斷是否以prefix參數開頭 start:起始位置;end結束位置"""

403 """

404 S.startswith(prefix[, start[, end]]) -> bool405

406 Return True if S starts with the specified prefix, False otherwise.407 With optional start, test S beginning at that position.408 With optional end, stop comparing S at that position.409 prefix can also be a tuple of strings to try.410 """

411 returnFalse412

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

414 """去除兩邊開始chars參數所代表的字元串(包括其子字元串可自由組合),沒有不去除(隻有前一個去了後面才能去),415 不填預設去除多餘空格還有('\t','\]n');"""

416 """

417 S.strip([chars]) -> str418

419 Return a copy of the string S with leading and trailing420 whitespace removed.421 If chars is given and not None, remove characters in chars instead.422 """

423 return ""

424

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

426 """大小寫轉換"""

427 """

428 S.swapcase() -> str429

430 Return a copy of S with uppercase characters converted to lowercase431 and vice versa.432 """

433 return ""

434

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

436 """将字元串轉換成标題形式"""

437 """

438 S.title() -> str439

440 Return a titlecased version of S, i.e. words start with title case441 characters, all remaining cased characters have lower case.442 """

443 return ""

444

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

446 """按照table參數表示的一一對應關系替換 變量中的值 ,傳回替換後的字元串"""

447 """

448 S.translate(table) -> str449

450 Return a copy of the string S in which each character has been mapped451 through the given translation table. The table must implement452 lookup/indexing via __getitem__, for instance a dictionary or list,453 mapping Unicode ordinals to Unicode ordinals, strings, or None. If454 this operation raises LookupError, the character is left untouched.455 Characters mapped to None are deleted.456 """

457 return ""

458

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

460 """将字元串中字母全部變成大寫"""

461 """

462 S.upper() -> str463

464 Return a copy of S converted to uppercase.465 """

466 return ""

467

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

469 """将字元串放在右邊和 width:代表寬度 ;預設用0填充"""

470 """

471 S.zfill(width) -> str472

473 Pad a numeric string S with zeros on the left, to fill a field474 of the specified width. The string S is never truncated.475 """

476 return ""