2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Tabula contentorum
Caput VI Res gestae et operationes dividendae
Filum: filum constans ex pluribus characteribus
Moribus: nudo oculo signa visibilia
Bytes: invisibilia nudo oculo
Quomodo Python chordas definit:
duplices quotes trina quotes str ( ) .
>>> dir(s) ['capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
capitalize ------- fac prima littera in linea auto
>>> s 'this is a string' >>> s.capitalize() 'This is a string'
Centrum (latitudo, fillchar='') ------ Centrum chorda secundum datam longi- tudinem et align eam in centro
rjust --------- ius varius
ljust noctis ------ sinistram
>>> help(s.center) Help on built-in function center: center(width, fillchar=' ', /) method of builtins.str instance Return a centered string of length width. Padding is done using the specified fill character (default is a space). >>> s.center(40) ' this is a string ' >>> s.center(40,"*") '************this is a string************' >>> s.rjust(40) ' this is a string' >>> s.ljust(40) 'this is a string ' >>> s.ljust(40,"*") 'this is a string************************' >>> s.rjust(40,"*") '************************this is a string'
numerare --------- numerat numerum temporum character apparet in filo
>>> s 'this is a string' >>> s.count("s") 3 >>> s.count("is") 2
endswith ------- an chorda cum XXX
incipitwith ------- utrum linea incipit cum XXX
>>> s.endswith("g") True >>> s.endswith("ing") True >>> s.endswith("f") False >>> s.startswith("t") True >>> s.startswith("f") False
index ------ Positio ubi character quaesita vel chorda primum in chorda apparet.
rindex ------- Investigatio a dextra ad sinistram, situs ubi prima indoles vel chorda quaesita apparet in chorda (aequivalet ad ultimum eventum characteris vel chordae inquisitionis a sinistra ad dextram in chorda) locus ), si non existit, exceptionem mitte.
>>> s 'this is a string' >>> s.index("s") 3 >>> s.index("is") 2 >>> s.index("f") Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: substring not found >>> s.index(" ") 4 >>> s.rindex("s") 10 >>> s.rindex("f") Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: substring not found
invenio ------- Locus ubi indoles vel chorda quaesita primum in chorda apparet.
rfind ----- Quaere a dextra ad sinistram, situs primi occursus characteris vel chordae in chorda (aequivalet ad positionem ultimi eventum characteris vel chordae in filo a sinistro ad dextrum) ) redit -1 si non est
>>> s 'this is a string' >>> s.find("s") 3 >>> s.find("f") -1 >>> s.rfind("f") -1 >>> s.rfind("s") 10
encode ----- methodus convertendi chordas ad bytes in python3, decode() methodum convertendi bytes ad chordas (ratio in bytes)
>>> s 'this is a string' >>> s.encode() b'this is a string' >>> d = s.encode() >>> d b'this is a string' >>> type(d) <class 'bytes'> >>> d b'this is a string' >>> d.decode() 'this is a string' >>> ss = d.decode() >>> ss 'this is a string' >>> type(ss) <class 'str'>
format ------ format filum, chordarum concatenatis
isupper ------ decernit an linea sit omnibus uppercase epistolas
islower ------- an filum est lowercase litteras
>>> s.isupper() False >>> s.islower() False
istitle ----- Decernite an sit titulus
>>> s.istitle() False >>> ss = "This Is A Dog" >>> ss.istitle() True
isspace ----- Non vulgo dicitur ad determinare an spatium sit.
>>> sss = " " >>> sss.isspace() True >>> ss 'This Is A Dog' >>> ss.isspace() False
isdigit ------ utrum sit numerus
>>> sss = "123234344" >>> sss.isdigit() True >>> ss 'This Is A Dog' >>> ss.isdigit() False >>> sss = "1233443gggg" >>> sss.isdigit() False
isalnum ------ an sit litteris et numeris (alpha-numeric)
>>> help(s.isalnum) Help on built-in function isalnum: isalnum() method of builtins.str instance Return True if the string is an alpha-numeric string, False otherwise. A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string. >>> sss '1233443gggg' >>> sss.isalnum() True >>> ss 'This Is A Dog' >>> ss.isalnum() False
isalpha ------ decernit an sit epistula
----- titulum convert filum ad titulum format
>>> s 'This is a string' >>> s.istitle() False >>> s.title() 'This Is A String' >>> sss = s.title() >>> sss 'This Is A String' >>> sss.istitle() True
converte ------- superius chorda ad auto
Infra ------- Convert linea ad lowercase
>>> s 'This is a string' >>> s.lower() 'this is a string' >>> s.upper() 'THIS IS A STRING'
fissura ----- chorda fissura secundum determinatum symbolum, et reditus pretii est index
>>> s 'This is a string' >>> s.split(" ") ['This', 'is', 'a', 'string'] >>> l = s.split(" ") >>> l ['This', 'is', 'a', 'string'] >>> type(l) <class 'list'> >>> l = s.split("s") >>> l ['Thi', ' i', ' a ', 'tring']
iungere ------ concatenare iterabile in filo secundum certa forma
>>> ls = ["A","B","c","d"] >>> type(ls) <class 'list'> >>> ss = " ".join(ls) >>> ss 'A B c d' >>> type(ss) <class 'str'> >>> ss = "*".join(ls) >>> ss 'A*B*c*d'
detrahe ------- distantiam utrimque
rstrip ------ purgare spatia dextra
lstrip -------- patet sinistram spatia
>>> ss = " hhhhhhh " >>> ss ' hhhhhhh ' >>> ss.strip() 'hhhhhhh' >>> ss.strip() 'hhhhhhh' >>> ss ' hhhhhhh ' >>> ss.rstrip() ' hhhhhhh' >>> ss.lstrip() 'hhhhhhh '
reponere ("originale character", "novi mores") ------ reponere characterem correspondentem
>>> s 'This is a string' >>> s.replace("s","t") 'Thit it a ttring'
Scalpere: iterabile obiecti ad separatum (continens)
Praecepta grammaticae:
object[start_index:end_index:step]
start_index ------- Satus index (incipiens loco)
end_index ------ index finis (positio finis), valorem non includit ad end_index
gradus ---- gradus magnitudine, potest esse numerus affirmativus vel numerus negativus, numerus affirmativus (a sinistro ad dextrum) numerus negativus (a dextra ad sinistram), defectus pretii est 1
object[:] ----- 切割的是一个完整的对象 object[start_index:] ------ 从start_index开始切割到最后的位置,步长为1 object[:end_index] ------ 从最开始的位置切割到end_index处,但是不包含end_index object[start_index:end_index] ------- 从start_index开始切割到end_index处,但是不包含end_index,步长为1 object[start_index:end_index:step] ------------ 从start_index开始切割到end_index处,但是不包含end_index,步长为step
Medium inter ostium ante occlusionem et retro
ls = [0,1,2,3,4,5,6,7,8,9]
1. secare unum valorem
>>> ls [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> ls[0] 0 >>> ls[-4] 6
2. Integram object
>>> ls[:] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> ls[::] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> ls[::-1] #-1 表示从右往左切割 所以是倒序 [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
3. start_index et end_index sunt numeri positivi
>>> ls [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> ls[1:6] [1, 2, 3, 4, 5] >>> ls[1:6:-1] # start_index=1 end_index = 6表示的是从1切割到6的位置,但是不包含6处的值,从左往右切割,step=-1 表示从右往左 [] >>> ls[6:1] [] >>> ls[6:1:-1] [6, 5, 4, 3, 2] >>> ls[:6] [0, 1, 2, 3, 4, 5] >>> ls[:6:-1] [9, 8, 7] >>> ls[6:] [6, 7, 8, 9] >>> ls[6::-1] [6, 5, 4, 3, 2, 1, 0] >>>
4. start_index et end_index sunt numeri negativi
>>> ls [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> ls[-1:-6] [] >>> ls[-1:-6:-1] [9, 8, 7, 6, 5] >>> ls[-6:-1] [4, 5, 6, 7, 8] >>> ls[:-6] [0, 1, 2, 3] >>> ls[:-6:-1] [9, 8, 7, 6, 5] >>> ls[-6:] [4, 5, 6, 7, 8, 9] >>> ls[-6::-1] [4, 3, 2, 1, 0]
5. Start_index et end_index coniunguntur cum positivis et negativis
>>> ls [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> ls[1:-6] [1, 2, 3] >>> ls[1:-6:-1] [] >>> ls[-1:6] [] >>> ls[-1:6:-1] [9, 8, 7]
6. Continua dividendo
>>> ls [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> ls[:8][2:5][-1:] [4] ls[:8] ----- [0,1,2,3,4,5,6,7] ls[:8][2:5] ----- [2,3,4] ls[:8][2:5][-1:] ----- [4]
7. tres moduli scindendi possunt etiam esse locutiones
>>> ls [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> ls[2+1:3*2:7%3] [3, 4, 5] >>> ls[3:6:1] [3, 4, 5] >>> ls[2:6:2] [2, 4]
8. Slicing potest etiam alia secare
>>> (1,2,3,4,5,6,7,8,9)[:3] (1, 2, 3) >>> "ABCDEFGHIJK"[::2] 'ACEGIK' >>> for i in range(1,100)[2::3][-10:]: ... print(i) ... 72 75 78 81 84 87 90 93 96 99
Colloquium quaestiones:
1. Si subscriptio range superatur, cum segmentis utentes ad notitias incisas, error erit referendus?
Nullus error referetur.
2. Quomodo in pythone album output regredi?
loop contra
[::-1]
list.reverse ()