Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASCII字符表Python 3_Python_Ascii - Fatal编程技术网

ASCII字符表Python 3

ASCII字符表Python 3,python,ascii,Python,Ascii,我试图制作一个ASCII列表,每行10行,每行间隔1个空格。我不能把他们分开而不把桌子弄乱。我希望它不要吐出一长排字符 这张桌子应该是这样的 ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r

我试图制作一个ASCII列表,每行10行,每行间隔1个空格。我不能把他们分开而不把桌子弄乱。我希望它不要吐出一长排字符

这张桌子应该是这样的

! " # $ % & ' ( ) *
+ , - . / 0 1 2 3 4 
5 6 7 8 9 : ; < = >
? @ A B C D E F G H
I J K L M N O P Q R 
S T U V W X Y Z [ \ 
] ^ _ ` a b c d e f 
g h i j k l m n o p 
q r s t u v w x y z 
{ | } ~ 
!" # $ % & ' ( ) *
+ , - . / 0 1 2 3 4 
5 6 7 8 9 : ; < = >
?A B C D E F G H
I J K L M N O P Q R
S T U V W X Y Z[\
](a b c d e f)
g h i j k l m n o p
q r s t u v w x y z
{ | } ~ 
这是我的密码:

for v in range(33,127):
    if v <= 42:
        print(chr(v), end = ' ')
    elif v >= 43 and v <= 52:
        print(chr(v), end = ' ')
    elif v >= 53 and v <= 62:
        print(chr(v), end = ' ')
    elif v >= 63 and v <= 72:
        print(chr(v), end = ' ')
    elif v >= 73 and v <= 82:
        print(chr(v), end = ' ')
    elif v >= 83 and v <= 92:
        print(chr(v), end = ' ')
    elif v >= 93 and v <= 102:
        print(chr(v), end = ' ')
    elif v >= 103  and v <= 112:
        print(chr(v), end = ' ')
    elif v >= 113  and v <= 122:
        print(chr(v), end = ' ')
    elif v >= 123 and v <= 127:
        print(chr(v), end = ' ')
    else:
        break
适用于范围内的v(33127):

如果v=43、v=53、v=63、v=73、v=83、v=93、v=103、v=113、v=123、vPython是一种非常灵活的语言。这将为您提供您想要的大部分内容:

print "\n".join(" ".join(map(chr, range(x, x+10))) for x in range(33, 128, 10))

这超出了最后一行中所需的最大值127。修复这一问题留给您作为练习。

Python是一种非常灵活的语言。这将为您提供所需的大部分内容:

print "\n".join(" ".join(map(chr, range(x, x+10))) for x in range(33, 128, 10))

这超出了最后一行中所需的最大值127。修复这一问题留给您作为练习。

Python是一种非常灵活的语言。这将为您提供所需的大部分内容:

print "\n".join(" ".join(map(chr, range(x, x+10))) for x in range(33, 128, 10))

这超出了最后一行中所需的最大值127。修复这一问题留给您作为练习。

Python是一种非常灵活的语言。这将为您提供所需的大部分内容:

print "\n".join(" ".join(map(chr, range(x, x+10))) for x in range(33, 128, 10))
这超出了最后一行中所需的最大值127。请将其作为练习进行修正。

以下是代码:

start = 33
end = 127
for v in range(start, end):
    if (start - v) % 10 == 0: # check if (start - v) is a multiple of 10
        print("")
    print(chr(v), end=' ')
代码如下:

start = 33
end = 127
for v in range(start, end):
    if (start - v) % 10 == 0: # check if (start - v) is a multiple of 10
        print("")
    print(chr(v), end=' ')
代码如下:

start = 33
end = 127
for v in range(start, end):
    if (start - v) % 10 == 0: # check if (start - v) is a multiple of 10
        print("")
    print(chr(v), end=' ')
代码如下:

start = 33
end = 127
for v in range(start, end):
    if (start - v) % 10 == 0: # check if (start - v) is a multiple of 10
        print("")
    print(chr(v), end=' ')

我想了解python3中的
.format
,所以我想出了一个简单的方法来实现这个技巧

print(5*' '+(16*'{:#4x}').format(*range(16)),
      *['{:#4x}|'.format(i*16) + (16*'{:4c}').format(*range(16*i,16*(i+1))) 
        for i in range(2,8)], sep="\n")
输出:

      0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf
0x20|       !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /
0x30|   0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?
0x40|   @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O
0x50|   P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _
0x60|   `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o
0x70|   p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~   
0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf
0x20 |!“#$%&'()*+,-/
0x30 | 0 1 2 3 4 5 6 7 8 9:;<=>?
0x40 |@A B C D E F G H I J K L M N O
0x50 | P Q R S T U V W X Y Z[\]_
0x60 |`a b c d e f g h i j k l m n o
0x70 | p q r s t u v w x y z{|}
不完全是按顺序排列的,但在我看来更美观一点


说明:
'{:#4x}.format(val)
输出
val
(一个假定的
int
)格式为十六进制(
x
),在一个4个字符宽(
4
)的字段中,前面有
0x
16*'{:4c}'
创建16个字段,4个字符宽,它们将
int
作为
char
格式,它们由表达式
*range(…)

提供,我想了解python3中的
.format
格式,所以我想出了一个单行程序来实现这个技巧

print(5*' '+(16*'{:#4x}').format(*range(16)),
      *['{:#4x}|'.format(i*16) + (16*'{:4c}').format(*range(16*i,16*(i+1))) 
        for i in range(2,8)], sep="\n")
输出:

      0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf
0x20|       !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /
0x30|   0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?
0x40|   @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O
0x50|   P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _
0x60|   `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o
0x70|   p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~   
0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf
0x20 |!"   #   $   %   &   '   (   )   *   +   ,   -   .   /
0x30 | 0 1 2 3 4 5 6 7 8 9:;<=>?
0x40 |@A B C D E F G H I J K L M N O
0x50 | P Q R S T U V W X Y Z[\]_
0x60 |`a b c d e f g h i j k l m n o
0x70 | p q r s t u v w x y z{|}
不完全是按顺序排列的,但在我看来更美观一点


说明:
'{:#4x}.format(val)
输出
val
(一个假定的
int
)格式为十六进制(
x
),在一个4个字符宽(
4
)的字段中,前面有
0x
16*{:4c}“
创建16个字段,4个字符宽,它们将
int
格式设置为
char
,由表达式
*range(…)
提供。我想了解python3中的
.format
格式,所以我想出了一个单行程序来实现这一技巧

print(5*' '+(16*'{:#4x}').format(*range(16)),
      *['{:#4x}|'.format(i*16) + (16*'{:4c}').format(*range(16*i,16*(i+1))) 
        for i in range(2,8)], sep="\n")
输出:

      0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf
0x20|       !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /
0x30|   0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?
0x40|   @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O
0x50|   P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _
0x60|   `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o
0x70|   p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~   
0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf
0x20 |!“#$%&'()*+,-/
0x30 | 0 1 2 3 4 5 6 7 8 9:;<=>?
0x40 |@A B C D E F G H I J K L M N O
0x50 | P Q R S T U V W X Y Z[\]_
0x60 |`a b c d e f g h i j k l m n o
0x70 | p q r s t u v w x y z{|}
不完全是按顺序排列的,但在我看来更美观一点


说明:
'{:#4x}.format(val)
输出
val
(一个假定的
int
)格式为十六进制(
x
),在一个4个字符宽(
4
)的字段中,前面有
0x
16*'{:4c}'
创建16个字段,4个字符宽,它们将
int
作为
char
格式,它们由表达式
*range(…)

提供,我想了解python3中的
.format
格式,所以我想出了一个单行程序来实现这个技巧

print(5*' '+(16*'{:#4x}').format(*range(16)),
      *['{:#4x}|'.format(i*16) + (16*'{:4c}').format(*range(16*i,16*(i+1))) 
        for i in range(2,8)], sep="\n")
输出:

      0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf
0x20|       !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /
0x30|   0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?
0x40|   @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O
0x50|   P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _
0x60|   `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o
0x70|   p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~   
0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf
0x20 |!"   #   $   %   &   '   (   )   *   +   ,   -   .   /
0x30 | 0 1 2 3 4 5 6 7 8 9:;<=>?
0x40 |@A B C D E F G H I J K L M N O
0x50 | P Q R S T U V W X Y Z[\]_
0x60 |`a b c d e f g h i j k l m n o
0x70 | p q r s t u v w x y z{|}
不完全是按顺序排列的,但在我看来更美观一点

说明:
“{:#4x}”。format(val)
输出
val
(一个假定的
int
)格式为十六进制(
x
),前面(
)有
0x
)的字段4字符