我要开始学python了

对,为了接触自动化测试,我准备开始学习python了。

下载地址:https://www.python.org/downloads/windows/

现在一般都下载3.X版本,和2.X版本有差别,新手还是上来就用新的吧哈哈

python 是脚本语言  也是面向对象,应该比java简单。

举个栗子

print("python")  

   ps 2.X版本的是不需要括号的,但是在3.X版本下,不加括号是会报语法错误的

c的语法不适用,语句结束时不用分号

我的第一个程序:(看的小甲鱼视频)

print("...........我的第一个python程序.........")
temp = input("请猜一个数字:")
guess = int(temp)
if guess==8:
    print("恭喜o")
else:
    print("猜错咯")
print("游戏结束")

这里想说一下,在python中,不用声明变量,直接拿来就能用啊。还有就是严格缩进,python不像java,c没有(){},所以是一个程序块一定要对齐!!!

>>> 5+8
13


这样算乘法都可以。9876654533567*1345667789900865431

>>> 9876654533567*1345667789900865431
13290695877799467816582939422377

这样都能算出来。


还有就是dif 的意思就是内置函数。

python又多少个内置函数呢。很多。怎么看!!

 dir(__builtins__)
我都粘贴过来吧。

['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TimeoutError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '_', '__build_class__', '__debug__', '__doc__', '__import__', '__loader__', '__name__', '__package__', '__spec__', 'abs', 'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', 'exit', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip']

看到这么多真是吓死宝宝了,那么怎么用呢

python 还有个help

嘿嘿

>>> help(input)
Help on built-in function input in module builtins:

input(...)
    input([prompt]) -> string
    
    Read a string from standard input.  The trailing newline is stripped.
    If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
    On Unix, GNU readline is used if enabled.  The prompt string, if given,
    is printed without a trailing newline before reading.

>>> 

出来都是英文的啊。能看懂当然最好了,看不懂,直接找翻译软件吧。。。

其他的 内置函数也可以这样用o













评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值