per page, with , order by , clip by
Results of 1 - 10 of about 108 for (' (0.008 sec.)
decimal --- 10進固定小数点と浮動小数点の演算 12439
decimal --- 10進固定小数点と浮動小数点の演算 ソースコード: Lib/decimal.py decimal モジュールは、高速で正しく丸められる 10 進浮動小数点演算をサポートします。 float データ型に比べて次のような利点があります: Decimal は「人間を念頭に設計された ... 要なだけ精度を高くできます: >>> from decimal import * >>> getcontext () . prec = 6 >>> Decimal ( 1 ) / Decimal ( 7 ) Decimal('0.142857') >>> getcontext () . prec = 28 >>> Decimal ( 1 ) / Decimal ( 7 ) Decimal('0.1428571428571428571428571429') 二進と ... aN や正負の Infinity (無限大)、 -0 といった特殊な値も表現できます: >>> getcontext () . prec = 28 >>> Decimal ( 10 ) Decimal('10') >>> Decimal ( '3.14' ) Decimal('3.14') >>> Decimal ( 3.14 ) Decimal('3.14000000000000012434497875801753252744674682617 ... 1875') >>> Decimal (( 0 , ( 3 , 1 , 4 ), - 2 )) Decimal('3.14') >>> Decimal ( str ( 2.0 ** 0.5 )) Decimal('1.4142135623730951') >>> Decimal ( 2 ) ** Decimal ( '0.5' ) Decimal('1.41 ...
https://man.mtool.work/python/3.14/library/decimal.html
ipaddress --- IPv4/IPv6 操作ライブラリ 11954
ipaddress --- IPv4/IPv6 操作ライブラリ ソースコード: Lib/ipaddress.py ipaddress は IPv4 と IPv6 のアドレスやネットワークを作成、操作する機能を提供します。 このモジュールの関数やクラスを使うと、IPアドレスに関する様々なタスク、例えば2つのホス ... されます。 address が正しい IPv4, IPv6 アドレスを表現していない場合は ValueError を発生させます。 >>> ipaddress . ip_address ( '192.168.0.1' ) IPv4Address('192.168.0.1') >>> ipaddress . ip_address ( '2001:db8::' ) IPv6Address('2001:db8::') ipaddress. ... 現していない場合や、ネットワークの host bit がセットされていた場合は ValueError を発生させます。 >>> ipaddress . ip_network ( '192.168.0.0/28' ) IPv4Network('192.168.0.0/28') ipaddress. ip_interface ( address ) 引数に渡された IP address に応じて、 I ... る整数。 大きさ4の bytes オブジェクトに (最上位オクテットが最初になるように) パックされた整数。 >>> ipaddress . IPv4Address ( '192.168.0.1' ) IPv4Address('192.168.0.1') >>> ipaddress . IPv4Address ( 3232235521 ) IPv4Address('192.168.0.1') >>> ipaddr ...
https://man.mtool.work/python/3.14/library/ipaddress.html
ソートのテクニック 10984
ソートのテクニック Author : Andrew Dalke and Raymond Hettinger Python のリストにはリストをインプレースに変更する、組み込みメソッド list.sort() があります。他にもイテラブルからソートしたリストを作成する組み込み関数 sorted() があります。 この ... 素を持つオブジェクトからインデックスで取り出した値をキーにしてソートすることです。 例を示します。 >>> student_tuples = [ ... ( 'john' , 'A' , 15 ), ... ( 'jane' , 'B' , 12 ), ... ( 'dave' , 'B' , 10 ), ... ] >>> sorted ( student_tuples , key = lambda ... student : student [ 2 ]) # 年齢でソート [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)] 同じテクニックは名前づけされた属性 (named attributes) を使うことでオ ... . def __repr__ ( self ): ... return repr (( self . name , self . grade , self . age )) >>> student_objects = [ ... Student ( 'john' , 'A' , 15 ), ... Student ( 'jane' , 'B' , 12 ), ... Student ( 'dave' , 'B' , 10 ), ... ] >>> sorted ( student_objec ...
https://man.mtool.work/python/3.14/howto/sorting.html
pathlib --- オブジェクト指向のファイルシステムパス 10653
pathlib --- オブジェクト指向のファイルシステムパス Added in version 3.4. ソースコード: Lib/pathlib/ このモジュールはファイルシステムのパスを表すクラスを提供していて、様々なオペレーティングシステムについての適切な意味論をそれらのクラスに持た ... 基本的な使い方 メインクラスをインポートします: >>> from pathlib import Path サブディレクトリの一覧を取得します: >>> p = Path ( '.' ) >>> [ x for x in p . iterdir () if x . is_dir ()] [PosixPath('.hg'), PosixPath('docs'), PosixPath('dist'), PosixPath( ... '__pycache__'), PosixPath('build')] このディレクトリツリー内の Python ソースファイルの一覧を取得します: >>> list ( p . glob ( '**/*.py' )) [PosixPath( ... 'test_pathlib.py'), PosixPath('setup.py'), PosixPath('pathlib.py'), PosixPath('docs/conf.py'), PosixPath('build/lib/pathlib.py')] ディレクトリツリー内を移 ...
https://man.mtool.work/python/3.14/library/pathlib.html
itertools --- 効率的なループ用のイテレータ生成関数群 10410
itertools --- 効率的なループ用のイテレータ生成関数群 このモジュールは イテレータ を構築する部品を実装しています。プログラム言語 APL, Haskell, SML からアイデアを得ていますが、 Python に適した形に修正されています。 このモジュールは、高速でメモ ... ) p [,func] p0, p0+p1, p0+p1+p2, ... accumulate([1,2,3,4,5]) → 1 3 6 10 15 batched() p, n (p0, p1, ..., p_n-1), ... batched('ABCDEFG', n=3) → ABC DEF G chain() p, q, ... p0, p1, ... plast, q0, q1, ... chain('ABC', 'DEF') → A B C D E F chain.from_it ... . chain.from_iterable(['ABC', 'DEF']) → A B C D E F compress() data, selectors (d[0] if s[0]), (d[1] if s[1]), ... compress('ABCDEF', [1,0,1,0,1,1]) → A C E F count() [start[, step]] start, start+step, start+2*step, ... count(10) → 10 11 12 13 14 . ... .. cycle() p p0, p1, ... plast, p0, p1, ... cycle('ABCD') → A B C D A B C D ... dropwhile() predicate, seq predicate が偽を返した位置からの seq[n], seq[n+1] dropwhile(lambda ...
https://man.mtool.work/python/3.14/library/itertools.html
ipaddressモジュールの紹介 9632
ipaddressモジュールの紹介 author : Peter Moody author : Nick Coghlan 概要 このドキュメントは ipaddress モジュールへのやさしい入門を提供するのが目的です。これは主にまだIPネットワーキングの用語に詳しくないユーザーを対象としていますが、 ipaddr ... を使用することで、この方法では渡された値をもとにIPv4かIPv6アドレスのどちらかを自動的に決定します: >>> ipaddress . ip_address ( '192.0.2.1' ) IPv4Address('192.0.2.1') >>> ipaddress . ip_address ( '2001:DB8::1' ) IPv6Address('2001:db8::1') アドレスは整 ... ることも可能です。32ビットに収まる値はIPv4アドレスであるとみなされます: >>> ipaddress . ip_address ( 3221225985 ) IPv4Address('192.0.2.1') >>> ipaddress . ip_address ( 42540766411282592856903984951653826561 ) IPv6Address('2001:db8::1') IPv4またはIPv6 ... す必要があります。これは特にIPv6アドレスを小さな整数で作成する場合に役立ちます: >>> ipaddress . ip_address ( 1 ) IPv4Address('0.0.0.1') >>> ipaddress . IPv4Address ( 1 ) IPv4Address('0.0.0.1') >>> ipaddress . IPv6Address ( 1 ) IPv6Address('::1') ネッ ...
https://man.mtool.work/python/3.14/howto/ipaddress.html
string.templatelib --- テンプレート文字列リテラルのサポート 8854
string.templatelib --- テンプレート文字列リテラルのサポート ソースコード: Lib/string/templatelib.py 参考 フォーマット済み文字列リテラル テンプレート文字列リテラル(t-string)の構文 PEP 750 テンプレート文字列 Added in version 3.14. テンプレート ... ックスとして 'f' の代わりに 't' を使用します: >>> pi = 3.14 >>> t 't-strings are new in Python { pi !s} !' Template( strings=('t-strings are new in Python ', '!'), interpolations=(Interpolation(3.14, 'pi', 's', ''),) ) 型 class string.templatelib. Te ... は補間される値を保持します。 >>> cheese = 'Camembert' >>> template = t 'Ah! We do have { cheese } .' >>> template . strings ('Ah! We do have ', '.') >>> template . interpolations (Interpolation('Camembert', ...),) >>> template . values ('Camembert', ... 1 つ多く、補間部分は文字列の間に入ります。 タプルの要素の位置をそろえて並べると分かりやすくなります。 template . strings : ( 'Ah! We do have ' , '.' ) template . values : ( 'Camembert' , ) 属性 strings : tuple [ str , ... ] テンプレート内の静的な文 ...
https://man.mtool.work/python/3.14/library/string.templatelib.html
webbrowser --- 便利なウェブブラウザコントローラー 8369
webbrowser --- 便利なウェブブラウザコントローラー ソースコード: Lib/webbrowser.py webbrowser モジュールは、ウェブ上のドキュメントをユーザーに表示するための高水準インターフェースを提供します。 ほとんどの場合、このモジュールの open() 関数を呼 ... ウザの名前と、それぞれのコントローラークラスのインスタンスを以下の表に示します。 Type Name Class Name 注釈 'mozilla' Mozilla('mozilla') 'firefox' Mozilla('mozilla') 'epiphany' Epiphany('epiphany') 'kfmclient' Konqueror() (1) 'konqueror' Konqueror() ... (1) 'kfm' Konqueror() (1) 'opera' Opera() 'links' GenericBrowser('links') 'elinks' Elinks('elinks') 'lynx' GenericBrowser('lynx') 'w3m' GenericBrowser('w3m') 'windows-default' WindowsDefaul ... t (2) 'macosx' MacOSXOSAScript('default') (3) 'safari' MacOSXOSAScript('safari') (3) 'google-chrome' Chrome('google-chrome') 'chrome' Chrome('chrome') 'chr ...
https://man.mtool.work/python/3.14/library/webbrowser.html
html.parser --- HTML と XHTML のシンプルなパーサー 7782
html.parser --- HTML と XHTML のシンプルなパーサー ソースコード: Lib/html/parser.py このモジュールでは HTMLParser クラスを定義します。このクラスは HTML (ハイパーテキスト記述言語、HyperText Mark-up Language) および XHTML で書式化されているテ ... , tag ) def handle_data ( self , data ): print ( "Encountered some data :" , data ) parser = MyHTMLParser () parser . feed ( '<html><head><title>Test</title></head>' '<body><h1>Parse me!</h1></body></html>' ) 出力は以下のようになります: Encountered ... ない属性では value は None です。 例えば、タグ <A HREF="https://www.cwi.nl/"> を処理する場合、このメソッドは handle_starttag('a', [('href', 'https://www.cwi.nl/')]) として呼び出されます。 属性値に含まれる実体参照は、 html.entities の定義に従ってすべ ... ( name ) このメソッドは、 &name; 形式の名前付き文字参照 ( &gt; など) を処理するために呼び出されます。 name は一般実体参照 ( 'gt' など) です。 このメソッドは convert_charrefs が偽の場合にだけ呼び出されます。 HTMLParser. handle_charref ( name ) この ...
https://man.mtool.work/python/3.14/library/html.parser.html
collections --- コンテナデータ型 7591
collections --- コンテナデータ型 ソースコード: Lib/collections/__init__.py このモジュールは、汎用の Python 組み込みコンテナ dict , list , set , および tuple に代わる、特殊なコンテナデータ型を実装しています。 namedtuple() 名前付きフィールドを ... s , argparse defaults = { 'color' : 'red' , 'user' : 'guest' } parser = argparse . ArgumentParser () parser . add_argument ( '-u' , '--user' ) parser . add_argument ( '-c' , '--color' ) namespace = parser . parse_args () command_line_args = { k : v ... ': 2, 'green': 1}) >>> # Hamlet で最も頻出する単語を 10 個見つける >>> import re >>> words = re . findall ( r '\w+' , open ( 'hamlet.txt' ) . read () . lower ()) >>> Counter ( words ) . most_common ( 10 ) [('the', 1143), ('and', 966), ('to', 762), ... ('of', 669), ('i', 631), ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)] class collections. Counter ( ** kwargs ) cla ...
https://man.mtool.work/python/3.14/library/collections.html
PREV 1 2 3 4 5 6 7 8 9 10 NEXT