Skip to main content

PCIO

Input from stdin by format. Values can distrubuted on different lines.

import pcio

# Input two integer numbers as tuple
a,b=pcio.input('ii')

# Input a list of integer numbers
arr=pcio.input(100,'i')

# Input a list of pair float numbers
arr=pcio.input(100,'ff')

# Input one symbol
pcio.input(1)

# Input one line by default
s=pcio.input()

Function raises EOFError on end of file and ValueError if value is not a number.

Input Format Description
i Integer number, skip spaces before number
f Float number, skip spaces before number
w Word, skip spaces before word
c One character as string
l One line as a string
L One line with new line as a string
a All input as one string

Also specialized variants

import pcio

a=pcio.input_int()
b=pcio.input_float()
c=pcio.input_char()
d=pcio.input_word()
e=pcio.input_line()

Print according to the format specified by the first argument.

import pcio

# Print by format
pcio.print("Hello, {}!\n", "world")

# Print a list separated by space and new line
arr=[1,2,3,10,12.2,'a']
pcio.println(arr)
# 1 2 3 10 12.2 a
pcio.println('{:02i}',arr) 
# 01 02 03 10 12 a
pcio.println('{!r}',arr)
# [1,2,3,10,12.2,'a']

If the first argument is not a string then the format '{} {} {}' is used where the number of parentheses is equal to the number of arguments.

Format contain "replacement fields" surrounded by curly braces {}. Anything that is not contained in braces is considered literal text, which is copied unchanged to the output. If you need to include a brace character in the literal text, it can be escaped by doubling: {{ and }}.

replacement_field ::=  "{" [arg_index] [format_spec] "}"
format_spec ::=  "!" "r" | ":" [align][sign]["0"][width]["." precision][type]
align  ::=  "<" | ">" | "^"
sign            ::=  "+" | "-"
width           ::=  digit+
precision       ::=  digit+
type            ::=  "i" | "d" | "o" | "x" | "X" | "e" | "E" | "f" | "F" | "g" | "G" | "s"

"!r" calls repr() to print.

The meaning of the various alignment options is as follows:

Option Meaning
'<' Forces the field to be left-aligned within the available space (this is the default for most objects).
'>' Forces the field to be right-aligned within the available space (this is the default for numbers).
'^' Forces the field to be centered within the available space.

The sign option is only valid for number types, and can be one of the following:

Option Meaning
'+' indicates that a sign should be used for both positive as well as negative numbers.
'-' indicates that a sign should be used only for negative numbers (this is the default behavior).

width is a decimal integer defining the minimum total field width, including any prefixes, separators, and other formatting characters. If not specified, then the field width will be determined by the content. Preceding the width field by a zero ('0') character enables zero-padding for numeric types.

The precision is a decimal integer indicating how many digits should be displayed after the decimal point for presentation types 'f' and 'F', or before and after the decimal point for presentation types 'g' or 'G'. For string presentation types the field indicates the maximum field size - in other words, how many characters will be used from the field content. The precision is ignored for integer presentation types.

The available types are:

Type Meaning
's' String format. Numbers is converted to the string ('g' or 'd') and precision is ignored.
'd', 'i' Decimal Integer. Outputs the number in base 10. String the 's' format is used instead.
'o' Octal format. Outputs the number in base 8. For float numbers and string the 'g' and 's' format is used instead.
'x', 'X' Hex format. Outputs the number in base 16.
'f', 'F' Fixed-point notation. For strings the 's' format is used and precision is ignored.
'e', 'E' Scientific notation.
'g', 'G' General format.

Select input/output encoding ('utf-8', 'cp1251' or 'cp866').

# Select encoding 
pcio.encoding('cp1251')

Metadata

Release files for pcio 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pcio 1.1.1
File Size Uploaded
pcio-1.1.1.tar.gz 11.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pcio 1.1.1
File Interpreter ABI Platform
pcio-1.1.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details

Total release size: 27.7 kB

Release files / pcio-1.1.1.tar.gz

Download URL pcio-1.1.1.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
78d528885cfe12d66d6ae4b4ce5179d4fbf8bcfd2b34396aaf3bc5f2310f16da
BLAKE2b-256 checksum
How to use checksums
c694341618155a59d81d7ff93ad5446fc5d835bfb6418b44aa5df31a2ae7e625
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / pcio-1.1.1-cp313-cp313-win_amd64.whl

Download URL pcio-1.1.1-cp313-cp313-win_amd64.whl
Size 16.3 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
d03c0b641a6ea80e802985c22d7867b58560efd8566b24cb9f7ebc1f4e438f95
BLAKE2b-256 checksum
How to use checksums
013fcd2531b8d85575619b06bbfb718d5f50ea2df6a5fccfff121433d0d6752a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page