用 *号输出字母 C的图案

方法1:

print("    *****   ")
print(" ** * ")
print(" ** ")
print(" ** ")
print(" ** * ")
print(" ***** ")

方法2:

ch = [[0, 1, 1, 0],
[1, 0, 0, 1],
[1, 0, 0, 0],
[1, 0, 0, 0],
[1, 0, 0, 1],
[0, 1, 1, 0]] for i in range(len(ch)):
for j in ch[i]:
if j == 0:
print(" ",end="")
else:
print("*", end=" ") print()

输出结果:

方法3:

from PIL import Image,ImageDraw,ImageFont
import numpy as np text = "C"
myfont = ImageFont.truetype("msyh.ttc", 12) # 在代码所在目录下需要放置字体文件,此处为msyh.tcc
size = myfont.getsize(text)
img = Image.new("", size, "black")
draw = ImageDraw.Draw(img)
draw.text((0,0), text, "white", font=myfont)
pixels = np.array(img, dtype=np.uint8)
chars = np.array([' ', '*'], dtype="U1")[pixels]
strings = chars.view('U' + str(chars.shape[1])).flatten()
print("\n".join(strings))

输出结果:

Python 3.X 练习集100题 05的更多相关文章

  1. Python 3.X 练习集100题 02

    企业发放的奖金根据利润提成.利润(I):低于或等于10万元时,奖金可提10%:高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%:20万到40万之间时,高 ...

  2. Python 3.X 练习集100题 03

    一个整数,它加上 100 后是一个完全平方数,再加上 168 又是一个完全平方数,请问该数是多少? import math for i in range(10000): n1 = math.sqrt( ...

  3. Python 3.X 练习集100题 01

    有以下几个数字:1.2.3.4.5,能组成多少个互不相同且无重复数字的三位数?都是多少? 方法1: import itertools from functools import reduce lyst ...

  4. Python 3.X 练习集100题 04

    输入某年某月某日,判断这一天是这一年的第几天? 方法1: import time test_time = input("请输入日期(年-月-日):") time_struct = ...

  5. Python练习100题

    Python练习100题 题目:有1.2.3.4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? #Filename:001.py cnt = 0#count the sum of res ...

  6. LeetCode 热题 HOT 100(05,正则表达式匹配)

    LeetCode 热题 HOT 100(05,正则表达式匹配) 不够优秀,发量尚多,千锤百炼,方可成佛. 算法的重要性不言而喻,无论你是研究者,还是最近比较火热的IT 打工人,都理应需要一定的算法能力 ...

  7. Python练习题 026:求100以内的素数

    [Python练习题 026] 求100以内的素数. ------------------------------------------------- 奇怪,求解素数的题,之前不是做过了吗?难道是想 ...

  8. Go面试题精编100题

    Golang精编100题 选择题 1.   [初级]下面属于关键字的是()A. funcB. defC. structD. class 参考答案:AC 2.   [初级]定义一个包内全局字符串变量,下 ...

  9. bzoj 前100题计划

    bzoj前100题计划 xz布置的巨大的坑.. 有空填题解... 1002 轮状病毒 用python手动matrixtree打表. #include<bits/stdc++.h> #def ...

随机推荐

  1. c#对象深复制demo

    public class Person : ICloneable { public string Name; object ICloneable.Clone() { return this.Clone ...

  2. linux系统下使用nginx反向代理asp.net core,并配置免费的https证书

    反向代理是为动态 Web 应用提供服务的常见设置. 反向代理终止 HTTP 请求,并将其转发到 ASP.NET Core 应用. 1.在asp.net core项目中的Startup的Configur ...

  3. Python基础12

    jupyter notebook 快捷键 ”Ctrl + / ” 快速注释/撤销注释.注释整行或者整段代码.

  4. Node.js自动本地重启服务器

    node.js在本地项目中,更新 了代码 是不会自动刷新 的,要重启才能生效,每次更改代码又手动重启这样很麻烦. 可以安装 个supervisor.全局安装supervisor npm install ...

  5. iOS开发使用Xcode的一些小技巧

    1.打开iOS项目 如果你当前目录下既有project又有workspace,你可以在终端使用命令“xed.”自动打开workspace,如果只有project,它会自动打开project. 2.清理 ...

  6. iOS相关

    1. fastlane a collection of tools that help you automate building and releasing iOS and Android apps ...

  7. 有些CRM settype用事务码COMM_ATTRSET打不开的原因

    This question is asked by Dr. Lin. Issue For example, settype COM_COMMERCIAL could be opened via tco ...

  8. Ubuntu拒绝root用户ssh远程登录

    sudo vim /etc/ssh/sshd_config 找到并用#注释掉这行:PermitRootLogin prohibit-password 新建一行 添加:PermitRootLogin y ...

  9. springBoot配置druid监控报错Failed to bind properties under 'spring.datasource.druid' to javax.sql.DataSource

    报错信息: Description: Failed to bind properties under 'spring.datasource.druid' to javax.sql.DataSource ...

  10. Spring Cloud微服务安全实战_3-1_API安全 常见的安全机制

    本章讲解,在不考虑微服务,只考虑一个简单的API ,如何保证这个API的安全? 三个问题: 1,什么是API ? 2,API安全的要素有哪些? 3,API安全基本机制 一.什么是API 百度百科:AP ...