实现Hello,World!的方式

简介: 实现Hello,World!的方式

实现Hello, world! 的方式:

 

先来几个python的

(注:使用的是python3.6版本):

方式1:

使用python + reportlab库 生成PDF文件

from reportlab.graphics.shapes import Drawing, String
from reportlab.graphics import renderPDF
 
d = Drawing(860, 480)
s = String(430, 240, 'Hello, world!', textAnchor='middle')
s.fontSize = 100
d.add(s)
 
renderPDF.drawToFile(d, 'hello.pdf', 'A simple PDF file')

运行后得到文件 hello.pdf

打开后看到:


方式2:

python + turtle库(turtle是很好用的1个图形库)

注:运行此程序可看到画图的过程

import turtle as t
#移动笔,而不在路径中画
def move_pen_to(t,x,y):
    t.up()
    t.goto(x,y)
    t.down()
 
#画H
def drawH(x,y):
    move_pen_to(t, x, y)
    t.goto(x, y-100)
    move_pen_to(t, x, y-50)
    t.goto(x+50, y-50)
    move_pen_to(t,x+50,y)
    t.goto(x+50,y-100)
 
#E
def drawE(x,y):
    move_pen_to(t, x, y)
    t.goto(x+50, y)
    move_pen_to(t, x, y)
    t.goto(x, y-100)
    move_pen_to(t, x, y-50)
    t.goto(x+50, y-50) 
    move_pen_to(t,x, y-100)
    t.goto(x+50, y-100) 
 
#画L
def drawL(x, y):
    move_pen_to(t,x,y)
    t.goto(x, y-100)
    t.goto(x+50, y-100)
 
#画O
def drawO(x, y):
    move_pen_to(t,x,y)
    t.goto(x, y-100)
    t.goto(x+50, y-100)
    t.goto(x+50, y)
    t.goto(x,y)
 
def drawW(x, y):
    move_pen_to(t, x, y)
    t.goto(x+(50/4),y-100)
    t.goto(x+(50/4)*2,y)
    t.goto(x+ (50/4)*3, y-100)
    t.goto(x+ (50/4)*4, y)
 
def drawR(x,y):
    move_pen_to(t, x, y)
    t.goto(x+50,y)
    t.goto(x+50,y-30)
    t.goto(x, y-30)
    move_pen_to(t, x, y)
    t.goto(x, y-100)
    move_pen_to(t, x, y-30)
    t.goto(x+50, y-100)
 
def drawD(x, y):
    move_pen_to(t, x, y)
    t.goto(x, y-100)
    t.circle(50,180)
 
 
#设置宽度和速度
t.width(5)
t.speed(2)
#起点x,y
x =-200
y = 200
 
drawH(x, y)
drawE(x+50+20, y)
drawL(x+50*2+20*2, y)
drawL(x+50*3+20*3, y)
drawO(x+50*4+20*4, y)
 
line2 = y -100-20
drawW(x, line2)
drawO(x+50+20, line2)
drawR(x+50*2+20*2, line2)
drawL(x+50*3+20*3, line2)
drawD(x+50*4+20*4, line2)
 

 

 


方式3:python print()

print("Hello, world")

 


方式4:C语言 printf()

#include<stdio.h>
int main()
{
  printf("Hello, world");
  return 0;
}

方式5:C++ cout

#include<iostream>
int main()
{
  std::cout << "Hello, world";
  return 0;
}

方式6:C++ cout

#include<iostream>
int main()
{
  using std::cout;
  cout<< "HH      HH\t" << "EEEEEEEEEE\t" << "LL        \t" << "LL        \t" << "OOOOOOOOOO\n"
    << "HH      HH\t" << "EE        \t" << "LL        \t" << "LL        \t" << "OO      OO\n"
    << "HH      HH\t" << "EE        \t" << "LL        \t" << "LL        \t" << "OO      OO\n"
    << "HHHHHHHHHH\t" << "EEEEEEEEEE\t" << "LL        \t" << "LL        \t" << "OO      OO\n"
    << "HH      HH\t" << "EE        \t" << "LL        \t" << "LL        \t" << "OO      OO\n"
    << "HH      HH\t" << "EE        \t" << "LL        \t" << "LL        \t" << "OO      OO\n"
    << "HH      HH\t" << "EEEEEEEEEE\t" << "LLLLLLLLLL\t" << "LLLLLLLLLL\t" << "OOOOOOOOOO\n";
  cout<< "\n\n";
  cout<< "WW  WW  WW\t" << "OOOOOOOOOO\t" << "RRRRRRRRRR\t" << "LL        \t" << "DDDDDD\n"
    << "WW  WW  WW\t" << "OO      OO\t" << "RR      RR\t" << "LL        \t" << "DD     DD\n"
    << "WW  WW  WW\t" << "OO      OO\t" << "RRRRRRRRRR\t" << "LL        \t" << "DD      DD\n"
    << "WW  WW  WW\t" << "OO      OO\t" << "R   RRR   \t" << "LL        \t" << "DD        DD\n"
    << "WW  WW  WW\t" << "OO      OO\t" << "R    RRR  \t" << "LL        \t" << "DD      DD\n"
    << "WW  WW  WW\t" << "OO      OO\t" << "R     RRR \t" << "LL        \t" << "DD     DD\n"
    << "WWWWWWWWWW\t" << "OOOOOOOOOO\t" << "R      RRR\t" << "LLLLLLLLLL\t" << "DDDDDD\n";
        
  system("pause");
  return 0;
}
 

方式7

Qt5

#include <QApplication>
#include <QLabel>
 
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
 
    QLabel label("Hello, world");
    label.show();
 
    return app.exec();
}

 


方式8

Java

 
public class hello {
 
  public static void main(String[] args) {
    System.out.println("Hello, world");
  }
 
}

相关文章
|
运维 Serverless Nacos
nacos常见问题之连接异常如何解决
Nacos是阿里云开源的服务发现和配置管理平台,用于构建动态微服务应用架构;本汇总针对Nacos在实际应用中用户常遇到的问题进行了归纳和解答,旨在帮助开发者和运维人员高效解决使用Nacos时的各类疑难杂症。
684 0
nacos常见问题之连接异常如何解决
|
SQL 存储 Java
Hive【Hive(八)自定义函数】
Hive【Hive(八)自定义函数】
|
8月前
|
人工智能 安全 API
最近谈论 SSE 和 WebSocket 的人越来越多的原因
实时通信已经成了大模型应用的标配。
1124 244
最近谈论 SSE 和 WebSocket 的人越来越多的原因
|
9月前
|
人工智能 Serverless API
《多模态数据信息提取》解决方案评测体验
《多模态数据信息提取》解决方案,主要是通过先进的人工智能技术,能够识别和解析各种格式的文件,包括文本、图像、音频和视频,从而提取出有价值的信息,大幅提升数据处理效率。
265 7
|
机器学习/深度学习 编解码 数据挖掘
Sentieon 应用教程 | 使用CNVscope进行CNV检测分析
CNVscope是Sentieon推出的一款基于机器学习的全基因组CNV分析检测模块。该模块主要用于检测大于5kb的拷贝数增加或缺失,方法是通过分析reads的深度信息,并结合断点检测等其他特征进行拷贝数判断。
135 1
|
easyexcel
你要的不固定列excel导入导出,它来啦!(四)
在上篇文章中,我们简单的介绍了 excel 导入导出技术实践方案,就目前而已,使用最多的开源框架主要有以下三类,分别是:
|
存储 算法 安全
|
缓存 前端开发 Java
【Spring 源码】 贯穿 Bean 生命周期的核心类之 AbstractAutowireCapableBeanFactory
【Spring 源码】 贯穿 Bean 生命周期的核心类之 AbstractAutowireCapableBeanFactory
|
JavaScript
type和interface的异同?
type和interface的异同?
301 0
|
自然语言处理 数据处理 API
零样本文本分类应用:基于UTC的医疗意图多分类,打通数据标注-模型训练-模型调优-预测部署全流程。
零样本文本分类应用:基于UTC的医疗意图多分类,打通数据标注-模型训练-模型调优-预测部署全流程。