循序渐进-python-02
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了循序渐进-python-02相关的知识,希望对你有一定的参考价值。
关键字和标识符
下列的标识符是 Python3 的关键字,并且不能用于通常的标识符。关键字必须完全按照下面拼写:
>>> help() Welcome to Python 3.5‘s help utility! If this is your first time using Python, you should definitely check out the tutorial on the Internet at http://docs.python.org/3.5/tutorial/. Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, symbols, or topics, type "modules", "keywords", "symbols", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose name or summary contain a given string such as "spam", type "modules spam". help> keywords Here is a list of the Python keywords. Enter any keyword to get more help. False def if raise None del import return True elif in try and else is while as except lambda with assert finally nonlocal yield break for not class from or continue global pass
Python 中 我们不需要为变量指定数据类型。所以你可以直接写出 num1 = 1
,这样变量 abc
就是整数类型。如果你写出 num2= 1.0
,那么变量 abc
就是浮点类型。
>>> num1=1 >>> num2=1.0 >>> name="wuxinglai" >>> print(type(num1)) <class ‘int‘> >>> print(type(num num1 num2 >>> print(type(num num1 num2 >>> print(type(num2)) <class ‘float‘> >>> print(type(name)) <class ‘str‘> >>>
通过上面的例子你应该理解了如何在 Python 中定义变量,也就是只需要输入变量名和值就行了。Python 也能操作字符串,它们用单引号或双引号括起来。
从键盘读取输入
[email protected]:~/file/1# vim input_age.py
#!/usr/bin/python3 #coding:utf8 number=int(input("Please Input your age:")) if number >= 18: print ("你已经是成年人 Your age is %s and You are already an adult" %number) else: print ("你是未成年 Your age is %s You are a minor" %number)
[email protected]:~/file/1# python3 input_age.py
Please Input your age:18
你已经是成年人 Your age is 18 and You are already an adult
r[email protected]:~/file/1# python3 input_age.py
Please Input your age:12
你是未成年 Your age is 12 You are a minor
本文出自 “有志者,事竟成” 博客,谢绝转载!
以上是关于循序渐进-python-02的主要内容,如果未能解决你的问题,请参考以下文章
Unity2019 增量式GC(使用时间片段执行GC,减少卡顿)