Results of 1 - 10 of about 47 for world (0.004 sec.)
- textwrap --- テキストの折り返しと詰め込み 13726
- textwrap --- テキストの折り返しと詰め込み ソースコード: Lib/textwrap.py textwrap モジュールは、実際の処理をすべて担う TextWrapper クラスと、いくつかの便利な関数を提供します。 1 つか 2 つの文字列を折り返したり詰め込んだりするだけなら、これら
...残りの文字数と placeholder との和が width 内に収まるように、末尾から単語が切り捨てられます: >>> textwrap . shorten ( "Hello world!" , width = 12 ) 'Hello world!' >>> textwrap . shorten ( "Hello world!" , width = 11 ) 'Hello [...]' >>> textwrap . shorte...n ( "Hello world" , width = 10 , placeholder = "..." ) 'Hello...' オプションのキーワード引数は、以下で説明する TextWrapper インスタンスの属...、出力の際に単一の改行文字に正規化されます。 例えば: def test (): # 空行を避けるため、最初の行を \ で終える s = ''' \ hello world ''' print ( repr ( s )) # 表示結果: ' hello\n world\n ' print ( repr ( dedent ( s ))) # 表示結果: 'hello\n world\n' バージ... - https://man.mtool.work/python/3.14/library/textwrap.html
- functools --- 高階関数と呼び出し可能オブジェクトの操作 11279
- functools --- 高階関数と呼び出し可能オブジェクトの操作 ソースコード: Lib/functools.py functools モジュールは、ほかの関数を操作したり返したりする高階関数のためのモジュールです。 一般に、このモジュールではあらゆる呼び出し可能オブジェクトを関数
...た個数の位置引数しか埋められません。 Placeholder の番兵が含まれる場合、呼び出し時にすべてを埋める必要があります。 >>> say_to_world = partial ( print , Placeholder , Placeholder , "world!" ) >>> say_to_world ( 'Hello' , 'dear' ) Hello dear world! say_to_...ools import partial , Placeholder as _ >>> remove = partial ( str . replace , _ , _ , '' ) >>> message = 'Hello, dear dear world!' >>> remove ( message , ' dear' ) 'Hello, world!' >>> remove_dear = partial ( remove , _ , ' dear' ) >>> remove_dear ( me...ssage ) 'Hello, world!' >>> remove_first_dear = partial ( remove_dear , _ , 1 ) >>> remove_first_dear ( message ) 'Hello, dear world!' Placehold... - https://man.mtool.work/python/3.14/library/functools.html
- socketserver --- ネットワークサーバーのフレームワーク 11279
- socketserver --- ネットワークサーバーのフレームワーク ソースコード: Lib/socketserver.py socketserver モジュールを使うと、ネットワークサーバを簡単に作成できます。 利用可能な環境 : not WASI. このモジュールは WebAssembly では動作しないか、利用
...rint ( "Received:" , received ) この例の出力は次のようになります: サーバー: $ python TCPServer.py 127.0.0.1 wrote: b'hello world with TCP' 127.0.0.1 wrote: b'python is nice' クライアント: $ python TCPClient.py hello world with TCP Sent: hello world wi...th TCP Received: HELLO WORLD WITH TCP $ python TCPClient.py python is nice Sent: python is nice Received: PYTHON IS NICE socketserver.UDPServer の例 サ...rue server_thread . start () print ( "Server loop running in thread:" , server_thread . name ) client ( ip , port , "Hello World 1" ) client ( ip , port , "Hello World 2" ) client ( ip , port , "Hello World 3" ) server . shutdown () この例の出力は次の... - https://man.mtool.work/python/3.14/library/socketserver.html
- tempfile --- 一時ファイルやディレクトリの作成 9774
- tempfile --- 一時ファイルやディレクトリの作成 ソースコード: Lib/tempfile.py このモジュールは一時ファイルやディレクトリを作成します。 サポートされている全てのプラットフォームで動作します。 TemporaryFile 、 NamedTemporaryFile 、 TemporaryDire
...>> import tempfile # 一時ファイルを作成してデータを書き込む >>> fp = tempfile . TemporaryFile () >>> fp . write ( b 'Hello world!' ) # ファイルからデータを読み取る >>> fp . seek ( 0 ) >>> fp . read () b'Hello world!' # ファイルを閉じると削除される >>>...ンテキストマネージャーを使って一時ファイルを作成する >>> with tempfile . TemporaryFile () as fp : ... fp . write ( b 'Hello world!' ) ... fp . seek ( 0 ) ... fp . read () b'Hello world!' >>> # ファイルは閉じられ、削除されている # コンテキストマネージャ...、名前を使って再び開く >>> with tempfile . NamedTemporaryFile ( delete_on_close = False ) as fp : ... fp . write ( b 'Hello world!' ) ... fp . close () ... # ファイルは閉じられているが、削除されていない ... # 名前を使ってファイルを再び開く ... with ope... - https://man.mtool.work/python/3.14/library/tempfile.html
- コルーチンとタスク 9576
- コルーチンとタスク この節では、コルーチンと Task を利用する高レベルの asyncio の API の概略を解説します。 コルーチン ソースコード: Lib/asyncio/coroutines.py async/await 構文で宣言された コルーチン は、 asyncio を使ったアプリケーションを書く
...のに推奨される方法です。例えば、次のコードスニペットは "hello" を出力し、そこから 1 秒待って "world" を出力します: >>> import asyncio >>> async def main (): ... print ( 'hello' ) ... await asyncio . sleep ( 1 ) ... print (...'world' ) >>> asyncio . run ( main ()) hello world 単にコルーチンを呼び出しただけでは、コルーチンの実行スケジュールは予約されてい...照してください。) コルーチンを await すること。次のコード片は 1 秒間待機した後に "hello" と出力し、 更に 2 秒間待機してから "world" と出力します: import asyncio import time async def say_after ( delay , what ): await asyncio . sleep ( delay ) print ( wh... - https://man.mtool.work/python/3.14/library/asyncio-task.html
- 拡張と埋め込み FAQ 9014
- 拡張と埋め込み FAQ C で独自の関数を作ることはできますか? はい。関数、変数、例外、そして新しいタイプまで含んだビルトインモジュールを C で作れます。これはドキュメント Python インタプリタの拡張と埋め込み で説明されています。 ほとんどの中級から
...ingIO クラスを使うことです: >>> import io , sys >>> sys . stdout = io . StringIO () >>> print ( 'foo' ) >>> print ( 'hello world!' ) >>> sys . stderr . write ( sys . stdout . getvalue ()) foo hello world! これと同じことをするカスタムオブジェクトは次の...lf . data . append ( stuff ) ... >>> import sys >>> sys . stdout = StdoutCatcher () >>> print ( 'foo' ) >>> print ( 'hello world!' ) >>> sys . stderr . write ( '' . join ( sys . stdout . data )) foo hello world! C から Python で書かれたモジュールにアク... - https://man.mtool.work/python/3.14/faq/extending.html
- asyncio --- 非同期 I/O 8634
- asyncio --- 非同期 I/O Hello World! import asyncio async def main (): print ( 'Hello ...' ) await asyncio . sleep ( 1 ) print ( '... World!' ) asyncio . run ( main ()) asyncio は async/await 構文を使い 並行処理の コードを書くためのライブラリ
... - https://man.mtool.work/python/3.14/library/asyncio.html
- 7. Input and Output 8634
- 7. Input and Output プログラムの出力方法にはいくつかの種類があります。 データを人間が読める形で出力することもあれば、将来使うためにファイルに書くこともあります。 この章では、こうした幾つかの出力の方法について話します。 7.1. Fancier Output F
...どちらの関数に対しても同じ表現を返します。一方、文字列は、2つの異なる表現を持っています。 いくつかの例です: >>> s = 'Hello, world.' >>> str ( s ) 'Hello, world.' >>> repr ( s ) "'Hello, world.'" >>> str ( 1 / 7 ) '0.14285714285714285' >>> x = 10 * 3.25...of x is 32.5, and y is 40000... >>> # 文字列に repr() を使うとクォートとバックスラッシュが追加される: >>> hello = 'hello, world \n ' >>> hellos = repr ( hello ) >>> print ( hellos ) 'hello, world\n' >>> # repr() の引数はどんな Python オブジェクトでも... - https://man.mtool.work/python/3.14/tutorial/inputoutput.html
- mmap --- メモリマップファイルのサポート 8451
- mmap --- メモリマップファイルのサポート 利用可能な環境 : not WASI. このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、 WebAssembly プラットフォーム を見てください。 Memory-mapped file objects behave like both bytearray a
...5 ]) # 表示する内容: b"Hello" # スライス表記で内容を更新する。 # 新しい内容は同じサイズでなければならない mm [ 6 :] = b " world! \n " # ... 標準のファイルメソッドでもう一度読む mm . seek ( 0 ) print ( mm . readline ()) # 表示する内容: b"Hello world!\...th 文の中でコンテキストマネージャとしても使えます: import mmap with mmap . mmap ( - 1 , 13 ) as mm : mm . write ( b "Hello world!" ) Added in version 3.2: コンテキストマネージャのサポート。 次の例では無名マップを作り親プロセスと子プロセスの間でデータの...やりとりをしてみせます: import mmap import os mm = mmap . mmap ( - 1 , 13 ) mm . write ( b "Hello world!" ) pid = os . fork () if pid == 0 : # 子プロセスの場合 mm . seek ( 0 ) print ( mm . readline ()) mm . close () 引数 filen... - https://man.mtool.work/python/3.14/library/mmap.html
- tokenize --- Python ソース用のトークナイザー 8451
- tokenize --- Python ソース用のトークナイザー ソースコード: Lib/tokenize.py The tokenize module provides a lexical scanner for Python source code, implemented in Python. The scanner in this module returns comments as tokens as well, making i
...( result ) . decode ( 'utf-8' ) コマンドラインからトークナイズする例。次のスクリプトが: def say_hello (): print ( "Hello, World!" ) say_hello () will be tokenized to the following output where the first column is the range of the line/column coordina...1,16: OP ':' 1,16-1,17: NEWLINE '\n' 2,0-2,4: INDENT ' ' 2,4-2,9: NAME 'print' 2,9-2,10: OP '(' 2,10-2,25: STRING '"Hello, World!"' 2,25-2,26: OP ')' 2,26-2,27: NEWLINE '\n' 3,0-3,1: NL '\n' 4,0-4,0: DEDENT '' 4,0-4,9: NAME 'say_hello' 4,9-4,10: OP '(...COLON ':' 1,16-1,17: NEWLINE '\n' 2,0-2,4: INDENT ' ' 2,4-2,9: NAME 'print' 2,9-2,10: LPAR '(' 2,10-2,25: STRING '"Hello, World!"' 2,25-2,26: RPAR ')' 2,26-2,27: NEWLINE '\n' 3,0-3,1: NL '\n' 4,0-4,0: DEDENT '' 4,0-4,9: NAME 'say_hello' 4,9-4,10: LPA... - https://man.mtool.work/python/3.14/library/tokenize.html