代码情诗——一份真情请查收
作者:互联网
- 有意参加了一个叫做“代码情诗”的比赛,做做记录。在这恍惚之日,寻求一丝宁静。
- 课余时间随便玩玩,大神路过不必在意。写博客记录只希望对需要帮助的人有所帮助
创意参考: https://www.taitaiblog.com/1314.html
大体框架:
- 控制台动态闪现书面内容,抒情自然
- 主题Patient ,逐步打印字符画
- turtle画爱心(代码来源于上面给出的参考链接)
- 控制台打印二维码,扫描可见文字内容
1. 控制台动态打印书面内容
- 在控制台中,每一行的打印是同时的,而要做到一个字一个字的打印,就要时刻清除缓冲区。
- 控制好sleep时间,效果就会更好
print("This is My love, without any cover up, without any reservations to say it\n")
time.sleep(1)
#字符串内容
str = [
"You may have heard a story.\n",
"One day the girl asked the boy, what does ABCDEFG mean? \n",
"The boy replied, \"a boy can do anything for a girl\"\n",
"The girl was touched\n",
"But someone told her, Don't forget the HIJK——\"He is just kidding\"\n",
"The girl replied: It doesn't matter even if he cheats me, there's LMNOP behind it\n",
"\"Love Must Need Our Patience\"\n"
]
print("")
for i in range(7):
for j in range(len(str[i])-1):
#单个字符的延迟时间
time.sleep(0.07)
print(str[i][j],end = '')
sys.stdout.flush()#清除缓冲区
time.sleep(0.5)#行与行的延迟时间
print("\n")
2. 主题Patient ,逐步打印字符画
- 一个简易的进度条,比较丑陋
- 字符画(有很多可以用图片转字符串的工具,或者用代码写也可以)打印,与上面同理
print("So, please let us wait patiently")
for i in range(20):
sys.stdout.write("=")
sys.stdout.flush()
time.sleep(0.5)
pic = [
"...................................................................................................",
".................................................................................*.,*..............",
"......................................................................./@@@@@@@`@@@@@@@@`..........",
".....................................................................*@@O\\O@@@@@@@@/`*[@@`.........",
".....................................................................=@/.=@@@@@^,@@@@]]@@^.........",
".....................................................................=@@/@@@O@@@@@@@@@O@@^.........",
".............................]]@@@@@@@@@@@@@@@@@\\`...................,@@@O`*@@@@@@@@@@@@@^.........",
".......................]@@@@@@@@@@@@@@@@@@@@@@@@@@@@\\`................*\\@@@@@@@@/`=@@@@@`..........",
"...................,@@@@@@/[`...................[@@@@@@\\................*[@@@@@OO@@@@@[............",
"................,@@@@/*..*..........................\\@@@@@`.................*\\O,O@@`.*.............",
"............../@@@[..............................,`...,@@@@\\.................*.....................",
"............/@@/........................................,@@@@`.....................................",
"........../@@`............................................[@@@^.........,......,@].................",
".........@@^...............................................,@@@^........=^.......*,................",
".......,@@...................................................@@@^.......,^.......=....=^...,@......",
"......,@/.....................................................@@@`......=@^..[\\..=`...=^..,/@......",
"......@^......................................................,@@@.......^*.../`.=^....@]/`.\\......",
".....@@........................................................=@@^.....*,[[*....,`.....*..........",
"....,@@.......................................,\\`...............@@@................................",
"....=@\\....................]@@`...............@@@@`.............=@@`...............................",
"....=@^....................@@@@/..............,@@@...............@@^...............................",
"....=@@....................,@\\.....................O@@@`........@@^...............................",
"....=@@............................................=@@@O.........@@^...............................",
"....=@@..............*]@@]`..........................,`..........\\@^...............................",
"....=@@^.............@@@@@^......................................@@^...............................",
".....@@@..............***........................................@/..........@@@@@@`...............",
".....=@@^.......................=@\\`......,@@@..................=@`.........=@@@@@@@`..............",
"......@@@`......................@@@@@@@@@@@@/`.................=@`..........=@@@`@@@@..............",
"......,@@@........................[@@@@@@/`...................=@`...........=@@@.\\@@@`..,]]]]],....",
".......=@@@................................................../@`............=@@@^=@@@@@@[@@@@`.....",
"........=@@@`...........................................,../@@*.............=@@@^*..**,@@@@........",
".........=@@@\\*.........................................,@@@/............*]@@@@@^......./@@^.......",
"..........,@@@@`......................................,@@@[.......]]/@@@@@@@@@/`......./@@@`.......",
"............\\@@@@\\`...............................*./@@@@@@@@@@@@@@@@@@@@@[...,,@@@@@@@@@@^........",
"..............\\@@@@@@^.............................=@/=@@@@@@@@@@/[[`.......,/@@@@@`,[@@/`.........",
".................[@@/.............................*.*.*...................]@@@@@/`.................",
"...................].................................................,]@@@@@@@`....................",
"..................,@@@^..................................`.......,/@@@@@@@@/.......................",
"................../@@@`.................................*=@@@@@@@@@@@@[............................",
"................./@@@^....................................@@@@@@@/[................................",
"................=@@@^.....................................\\@@@^....................................",
"..............*=@@@/......................................=@@@^....................................",
"...............@@@@......./@@@@`...........................@@@@....................................",
"............../@@@`...*,@@@@@@^............................@@@@....................................",
".............=@@@/.../@@@@/@@@^............................O@@@....................................",
".............@@@@.,@@@@@`.,@@@^...........................**.......................................",
"............=@@@@@@@@/.....@@@@....................................................................",
".............[@@@@[................................................................................",
"...................................................................................................",
]
# 动态打印字符画
print("")
for i in range(49):
for j in range(len(pic[i])-1):
time.sleep(0.001)
print(pic[i][j],end='')
sys.stdout.flush()
print("")
3.turtle画爱心(代码来源于上面给出的参考链接)
#画爱心的圆弧部分
def hart_arc():
for i in range(200):
turtle.right(1)
turtle.forward(2)
# 移动turtle
def move_pen_position(x,y):
turtle.hideturtle()
turtle.up()
turtle.goto(x,y)
turtle.down()
turtle.showturtle()
#love 为爱心中间的字符串
love = 'My Love'
#画爱心
turtle.setup(width = 800,height = 500)
turtle.color('red','pink')
turtle.pensize(3)
turtle.speed(1)
move_pen_position(x=0,y=-180)
turtle.left(140)
turtle.begin_fill()
turtle.forward(224)
hart_arc()
turtle.left(120)
hart_arc()
turtle.forward(224)
turtle.end_fill()
move_pen_position(0,0)
turtle.hideturtle()
turtle.color('#CD5C5C','pink')
turtle.write(love,font = ('Arial',30,'bold'),align = 'center')
move_pen_position(0,-220)
turtle.hideturtle()
#画个心,心里面装的都是你
turtle.write("I have somehing to tell you, \
it is hidden in the two-dimensional code, \
please close this window",font = ('Arial',11,'bold'),align = 'center')
turtle.done()
4.控制台打印二维码,扫描可见文字内容
- 由于能力受限,二维码是由一个二维数组构成的(33*33)
#include <bits/stdc++.h>
using namespace std;
int a[35][35] = {
{1,1,1,1,1,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,1,1},
{1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,0,0,0,1,0,0,0,0,0,1},
{1,0,1,1,1,0,1,0,1,0,0,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1,1,1,1,1,0,1,1,0,1,0,1,1,0,0,0,0,0}
};
int main(){
unsigned int block = 32936;
system("color f0");
puts("");
for(int i=0;i<33;i++){
for(int j=0;j<33;j++){
if(a[i][j])printf("%s",&block);
else printf(" ");
}
puts("");
}
getchar();
return 0;
}
- 然后python调用
s = "QRcode.exe"
r_v = os.system(s)
print(r_v)
标签:turtle,......,....,.......,..............,.........,情诗,查收,真情 来源: https://www.cnblogs.com/1625--H/p/10705763.html