Python3基础 input 输入浮点数,整数,字符串

?

  • ???????Python : 3.7.0
  • ?????????OS : Ubuntu 18.04.1 LTS
  • ????????IDE : PyCharm 2018.2.4
  • ??????Conda : 4.5.11
  • ???typesetting : Markdown

?

code

"""
@Author : 行初心
@Date   : 18-9-24
@Blog   : www.cnblogs.com/xingchuxin
@Gitee  : gitee.com/zhichengjiu
"""

def main():
    my_float = float(input('请输入一个浮点数:'))
    my_int = int(input('请输入一个整数:'))
    my_str = input('请输入一个字符串:')

if __name__ == '__main__':
    main()

?

result

/home/coder/anaconda3/envs/py37/bin/python /home/coder/PycharmProjects/basic/demo.py
请输入一个浮点数:1.2
请输入一个整数:25
请输入一个字符串:hello

Process finished with exit code 0

?

more knowledge

Help on built-in function input in module builtins:

input(prompt=None, /)
    Read a string from standard input.  The trailing newline is stripped.

    The prompt string, if given, is printed to standard output without a
    trailing newline before reading input.

    If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.
    On *nix systems, readline is used if available.

?

resource

  • [文档] docs.python.org/3
  • [规范] www.python.org/dev/peps/pep-0008
  • [规范] zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_language_rules
  • [源码] www.python.org/downloads/source
  • [ PEP ] www.python.org/dev/peps
  • [平台] www.cnblogs.com
  • [平台] gitee.com

?



Python具有开源、跨平台、解释型、交互式等特性,值得学习。
Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。
代码的书写要遵守规范,这样有助于沟通和理解。
每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。

原文地址:https://www.cnblogs.com/xingchuxin/p/10433437.html

时间: 2024-08-29 12:48:54

Python3基础 input 输入浮点数,整数,字符串的相关文章

JavaSE8基础 要求输入给定的字符串,只有三次机会

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        code: package jizuiku.t02; import java.util.Scanner; public class Demo04 { public static void main(String[] args) { String keyWord = "jizuiku"; String use

Python3基础 str capitalize 返回新字符串,第一个字母大写

? python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 conda : 4.5.11 type setting : Markdown ? code [email protected]:~$ source activate py37 (py37) [email protected]:~$ ipython Python 3.7.0 (default, Jun 28 2018, 13:15:42) Type 'copyright'

Python3基础 len函数 获得一个字符串的字符个数

镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ 1 code 1 aStr='hello' 2 print(len(aStr)) 2 show ------------------------------------------博文的精髓,在技术部分,更在镇场一诗.Python是优秀的语言,值得努力学习.我是跟着小甲鱼视频教程学习的,推荐.如果

Python3基础 列表乘一个整数 扩增列表

镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ 1 code 1 list1=[1,2] 2 list2=list1*3 3 print(list2) 2 show ------------------------------------------博文的精髓,在技术部分,更在镇场一诗.Python是优秀的语言,值得努力学习.我是跟着小甲鱼视频

Python3基础 str *运算 重复拼接字符串

? python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 conda : 4.5.11 type setting : Markdown ? code [email protected]:~$ source activate xingchuxin (xingchuxin) [email protected]:~$ ipython Python 3.7.0 (default, Jun 28 2018, 13:15:42) Type

Python3基础 str partition 以参数字符串切分字符串,只切分为三部分

? python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 conda : 4.5.11 type setting : Markdown ? code [email protected]:~$ source activate py37 (py37) [email protected]:~$ ipython Python 3.7.0 (default, Jun 28 2018, 13:15:42) Type 'copyright'

Python3基础 str count 获得子字符串出现的次数

? python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 conda : 4.5.11 type setting : Markdown ? code [email protected]:~$ source activate py37 (py37) [email protected]:~$ ipython Python 3.7.0 (default, Jun 28 2018, 13:15:42) Type 'copyright'

Python3基础 print %d 输出整数

? ???????Python : 3.7.0 ?????????OS : Ubuntu 18.04.1 LTS ????????IDE : PyCharm 2018.2.4 ??????Conda : 4.5.11 ???typesetting : Markdown ? code coder@Ubuntu:~$ source activate py37 (py37) coder@Ubuntu:~$ ipython Python 3.7.0 (default, Jun 28 2018, 13:1

python基础数据类型----整数 ,字符串【常用操作方法】,布尔值,for循环

Python基础数据类型(4.29) bool str int 三者之间的转换 str索引切片,常用操作方法 for循环(大量的练习题) 1.基础数类型总览 整数(int) ,字符串(str),布尔值(bool),列表(list),元组(tuple),字典(dict),集合(set). 10203 123 3340 int 主要用于计算+- * / 等等 '今天吃了没?' str 存储少量的数据,并进行相应的操作.str1 + str2, str *int , 索引,切片, 其他操作方法 Tru