python小趣味_520繪製一個心形.

來源:互聯網
上載者:User

標籤:一個   utf-8   set   ack   div   上線   class   pytho   ali   

從某個公眾號上看到的. 跑了一下, 居然可以成功運行. 

有心的話可以研究下代碼.

#!/usr/bin/env python# coding:utf-8import turtleimport time# 畫愛心的頂部def LittleHeart():    for i in range(200):        turtle.right(1)        turtle.forward(2)# 輸入表白的語句,預設I Love youlove = input(‘Please enter a sentence of love, otherwise the default is "I Love you": ‘)# 輸入署名或者贈誰,沒有不執行me = input(‘Please enter pen name, otherwise the default do not execute: ‘)if love == ‘‘:    love = ‘I Love you‘# 視窗大小turtle.setup(width=900, height=500)# 顏色turtle.color(‘red‘, ‘pink‘)# 筆粗細turtle.pensize(3)# 速度turtle.speed(1)# 提筆turtle.up()# 隱藏筆turtle.hideturtle()# 去到的座標,視窗中心為0,0turtle.goto(0, -180)turtle.showturtle()# 畫上線turtle.down()turtle.speed(1)turtle.begin_fill()turtle.left(140)turtle.forward(224)# 調用畫愛心左邊的頂部LittleHeart()# 調用畫愛右邊的頂部turtle.left(120)LittleHeart()# 畫下線turtle.forward(224)turtle.end_fill()turtle.pensize(5)turtle.up()turtle.hideturtle()# 在心中寫字 一次turtle.goto(0, 0)turtle.showturtle()turtle.color(‘#CD5C5C‘, ‘pink‘)# 在心中寫字 font可以設定字型自己電腦有的都可以設 align開始寫字的位置turtle.write(love, font=(‘gungsuh‘, 30,), align="center")turtle.up()turtle.hideturtle()time.sleep(2)# 在心中寫字 二次turtle.goto(0, 0)turtle.showturtle()turtle.color(‘red‘, ‘pink‘)turtle.write(love, font=(‘gungsuh‘, 30,), align="center")turtle.up()turtle.hideturtle()# 寫署名if me != ‘‘:    turtle.color(‘black‘, ‘pink‘)    time.sleep(2)    turtle.goto(180, -180)    turtle.showturtle()    turtle.write(me, font=(20,), align="center", move=True)# 點擊視窗關閉window = turtle.Screen()window.exitonclick()

 

python小趣味_520繪製一個心形.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.