第一种方法
def fahrenheit_converter(g):
fahrenheit = g /1000
return str(fahrenheit) + 'kg' #调用函数
g2kg = fahrenheit_converter(3000)
print(g2kg) #打印结果 第二种方法
def g2kg(g):
return str(g/1000) + 'kg'
print(g2kg(2000)) #调用函数并打印结果

python-简单函数小例子 单位转换的更多相关文章

  1. 感受python之美,python简单易懂的小例子

    前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 1 简洁之美 通过一行代码,体会Python语言简洁之美 2 Python ...

  2. python闭包小例子

    ------------------ 首先根据实例, 体会一下闭包的效果 ------------------ 定义闭包: def foo(x): a = [0] def bar(y): a[0] = ...

  3. python ctypes小例子

    import time import ctypes import ctypes.wintypes SEE_MASK_NOCLOSEPROCESS = 0x00000040 SEE_MASK_INVOK ...

  4. [Python]Python 函数调用小例子

    函数定义: In [78]: def printme(str): ....: print str ....: return ....: 调用: In [79]: printme('This is Ji ...

  5. python subprocess 小例子

    #服务端import socketimport osimport subprocessphone = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ...

  6. [Spark][Hive][Python][SQL]Spark 读取Hive表的小例子

    [Spark][Hive][Python][SQL]Spark 读取Hive表的小例子$ cat customers.txt 1 Ali us 2 Bsb ca 3 Carls mx $ hive h ...

  7. [Python]Python 使用 for 循环的小例子

    [Python]Python 使用 for 循环的小例子: In [7]: for i in range(5): ...: print "xxxx" ...: print &quo ...

  8. [python]python 遍历一个list 的小例子:

    [python]python 遍历一个list 的小例子: mlist=["aaa","bbb","ccc"]for ss in enume ...

  9. C#中把任意类型的泛型集合转换成SQLXML数据格式的小例子

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

随机推荐

  1. php的json_encode()之后float类型丢失精度

    在后台php中,金额保留两位小数.但是前端显示精度丢失,出现了14位小数的奇怪现象.本来以为是前端js解析之后出现的问题.检查之后发现json_encode()之后就出现了. 原始的值: array( ...

  2. 记录numpy和c++的混合编程

    准备记录numpy和c++的混合编程 #include <boost/python.hpp> #include <numpy/ndarrayobject.h> namespac ...

  3. PYTHON之爬虫学习(一)基础

    关于python爬虫,大家都很熟悉,那么我就不多说,开始做了. 首先,python爬虫先安装python库,主要是requests库,在windows中cmd中输入,pip install reque ...

  4. Java高级架构师(一)第38节:Nginx的负载均衡模块

    负载均衡: 1.热备:如果你有2台服务器,当一台服务器发生事故时,才启用第二台服务器给提供服务.服务器处理请求的顺序:AAAAAA突然A挂啦,BBBBBBBBBBBBBB..... upstream ...

  5. Smart config风险分析与对策

    Smart config风险分析与对策 1.简介:          Smart config是一种将未联网设备快速连接wifi的技术,大概原理如下图所示: 2.业务需求:          要求实现 ...

  6. PHP5.3配置文件php.ini-development和php.ini-production的区别

    PHP5.3版本中出现了php.ini-developmen和php.ini-production PHP配置文件与PHP5.2版本相比,命名发生了变化: php.ini-production 对应于 ...

  7. ELK集群模式部署

    架构拓扑图为: 准备工作: 下载资源包: Elasticsearch: wget https://artifacts.elastic.co/downloads/elasticsearch/elasti ...

  8. lykchat信息发送系统

    lykchat信息发送系统是Python3开发的,通过模拟微信网页端,基于个人微信号,为系统管理人员提供信息发送工具. 实现的功能有用户登录管理.微信登陆管理和微信信息发送功能. 代码地址:https ...

  9. zabbix3.2 报错 Database error

    一.Database errorThe frontend does not match Zabbix database. Current database version (mandatory/opt ...

  10. unity shader 编译时间过长

    去掉opengles2.0能省一半时间 换ssd  Compiled shader 'Shader Forge/Scenes_Ground_Standard_M' in 315.51s    gles ...