python 基本的GPUG标志,使用呃...标志

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 基本的GPUG标志,使用呃...标志相关的知识,希望对你有一定的参考价值。

# -*- coding: utf-8 -*-
"""
Created on Fri May 16 09:04:31 2014

@author: tobie nortje @tooblippe

GPUG LOGO - just for fun
"""

from turtle import Turtle

t = Turtle()

#shorter functions names
l = t.left
r = t.right
f = t.fd
b = t.back
pu = t.pu
pd = t. pd
pf = t.pd
goto = t.goto

#scaling
scale = 3.0 # scaling factor - smaller makes GPUG bigger
line_color = 'black'
line_weight = '2'

t.pensize(line_weight)


g = [
    (l, 90),
    (f, 100),
    (l, 90),
    (f, 50),
    (l, 90),
    (f, 50),
    (pu, None),
    (f, 50),
    (l, 90),
    (f, 50),
    (r, 180),
    (pd, None),
    (f, 100),
    (r, 90),
    (f, 200),
    (r, 90),
    (f, 100)
   ]

p = [ (pu, None),
     (f, 10),
     (pd, None),
     (f, 100),
     (r, 90),
     (f, 100),
     (r, 90),
     (f, 100),
     (r, 90),
     (f, 100),
     (b, 200)
     ]

u = [ (r, 90),
      (pu, None),
      (f, 120),
      (pd, None),
      (l, 90),
      (f, 200),
      (b, 200),
      (r, 90),
      (f, 100),
      (l, 90),
      (f, 200),
      (b, 200),
      (r,90),
      (pu, None),
      (f, 120),
      (pd, None)
      ]

#lets draw GPUG

gpug_logo = [ g, p, u, g]

def do( (command, parameter)):
    if command == f or command == b:
        parameter = parameter / scale
        
    if command == goto:
        pu()
        command( parameter)
        pd()
    elif command == pu: pu()
    elif command == pd: pd()
    else:
        command(parameter)
        
for letter in gpug_logo : 
    for command in letter:
        do(command)

t.hideturtle()
print "press CTR-C to exit"
while True:
    pass

以上是关于python 基本的GPUG标志,使用呃...标志的主要内容,如果未能解决你的问题,请参考以下文章

Python3 使用基本循环实现多级目录(思路)

在 Python 中使用 -q 标志

python3.5中的标志位

在 python re.findall 中使用多个标志

Python Argparse:使用空标志

python基础知识--标志位的设定