百科问答小站 logo
百科问答小站 font logo



如何评价 Python 基础知识难度大吗? 第1页

  

user avatar   xiao-wu-ge-89-82 网友的相关建议: 
      

任何语言都是有单词组成句子,然后形成表达,计算机语言也不例外,对于Python基础,我觉得可以按照英语来学。当你把下面这些单词每个都记住的时候,Python基础基本也就会了。

在Python3中,最基础的是74个内置函数,通用的函数,还有有6个基准的的数据类型:Number(数字)String(字符串)List(列表)Tuple(元组)Set(集合)Dictionary(字典),每种类型有其固有的属性和方法,学会这六种数据类型及基础的方法,很多代码基本上都能看得懂,很多功能也都能实现了。要是实现面向百度编程到面向自己编程的转变,必须搞搞清楚这六大数据类型的属性和方法。

内置函数模块

       print(dir(__builtins__)) 'abs', 'all', 'any', 'ascii', 'bin', 'bool', 'breakpoint', 'bytearray', 'bytes', 'callable',  'cell_count', 'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits', 'debugcell',  'debugfile', 'delattr', 'dict', 'dir', 'display', 'divmod', 'enumerate', 'eval', 'exec',  'filter', 'float', 'format', 'frozenset', 'get_ipython', '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', 'range', 'repr', 'reversed', 'round', 'runcell',  'runfile', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple',  'type', 'vars', 'zip'     

字符串模块

       print(dir(str())) 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format',  'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier',  'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower',  'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit',  'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper',  'zfill'     

字典模块

       print(dir(dict())) 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update',  'values'     

集合模块:

       print(dir(dict())) 'add', 'clear', 'copy', 'difference', 'difference_update', 'discard', 'intersection',  'intersection_update', 'isdisjoint', 'issubset', 'issuperset', 'pop', 'remove',  'symmetric_difference', 'symmetric_difference_update', 'union', 'update'     

列表模块

       print(dir(list())) 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse',  'sort'     

元组模块

       print(dir(tuple())) 'count', 'index'     

数字模块

主要有两个模块的函数需要掌握,一个是math,一个是random

       import math print(dir(math)) 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh',  'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp',  'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma',  'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'remainder', 'sin', 'sinh',  'sqrt', 'tan', 'tanh', 'tau', 'trunc'     
       import random print(dir(random)) 'choice', 'choices', 'expovariate', 'gammavariate', 'gauss', 'getrandbits', 'getstate', 'lognormvariate',  'normalvariate', 'paretovariate', 'randint', 'random', 'randrange', 'sample', 'seed', 'setstate',  'shuffle', 'triangular', 'uniform', 'vonmisesvariate', 'weibullvariate'     


把上面所有的函数都实践并理解一遍,然后学一些函数、类、条件啥的,基本问题能解决了。然后再往深了学。第一个阶段基本上背诵加实践就可以。第二阶段,根据自己的方向,爬虫也好,算法也好,开发也好,单独补充下。




  

相关话题

  为什么 Python 的 GIL 问题一直让人诟病,Python 社区却不解决? 
  Python中使用class()有什么优势 (PS:想知道实际应用中的优势)? 
  python爬虫如何处理.js链接? 
  vlang,nim等新兴语言未来是否有可能掀翻go,rust,Python等老牌热门语言的霸主地位? 
  为什么Python,Go,Rust等新语言都不支持函数重载? 
  为什么很多人喜欢 Python? 
  GitHub 上有哪些,简单、易学的 Python 项目? 
  Python 应该怎么学? 
  python到底学什么? 
  如何评价 Python 基础知识难度大吗? 

前一个讨论
有哪些由中国团队在顶刊发表的文章创造了巨大的社会经济效益?
下一个讨论
能用高等数学手段研究人文社科问题吗?





© 2024-05-21 - tinynew.org. All Rights Reserved.
© 2024-05-21 - tinynew.org. 保留所有权利