百科问答小站 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 爬虫? 
  学校和机构都建议孩子放弃 Python 转 C++,我该如何处理? 
  python适合什么年龄自学? 
  Python如何实现list元素的两两相加并返回最大值? 
  Python中一个字符串的所有字母用它的后继字母代替(比如,a用b代替,b用c代替),怎么搞? 
  Python 打包成 exe,太大了该怎么解决? 
  如何看待中科院计算所发布的“木兰”国产编程语言其实基于Python3,并非完成“自主研发”? 
  Python 的练手项目有哪些值得推荐? 
  如何看待 Python 3.9 以上的版本不再支持 Windows 7? 
  Python 中有什么不容易让人察觉的有趣的事实? 

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





© 2025-03-28 - tinynew.org. All Rights Reserved.
© 2025-03-28 - tinynew.org. 保留所有权利